Le tridi 13 germinal, an CCXXV, Steven Liu a écrit : > I have implementation the av_strreplace use AVBprint, the API context now > is:
No need to Cc mo. On the other hand, sending the function itself instead
of the diff makes it easier in this case, thanks.
Nice. Just one issue:
> char *av_strreplace(const char *str, const char *from, const char *to)
> {
> char *ret = NULL;
> const char *pstr2, *pstr = str;
> size_t tolen = strlen(to), fromlen = strlen(from);
> AVBPrint pbuf;
>
> av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
> while ((pstr2 = av_stristr(pstr, from))) {
> av_bprint_append_data(&pbuf, pstr, pstr2 - pstr);
> pstr = pstr2 + fromlen;
> av_bprint_append_data(&pbuf, to, tolen);
> }
> av_bprint_append_data(&pbuf, pstr, strlen(pstr));
> av_bprint_finalize(&pbuf, &ret);
Just before that, a check with av_bprint_is_complete() is needed because
some malloc may have failed: if it is not complete, av_bprint_finalize()
to NULL to free the buffer and return NULL.
>
> return ret;
> }
Also, did you consider extending libavutil/tests/avstring.c to cover
this new function?
Regards,
--
Nicolas George
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
