[sr-dev] str_str function

Henning Westerholt hw at kamailio.org
Thu Jun 14 15:26:18 CEST 2012


Am Mittwoch, 13. Juni 2012, 19:17:02 schrieb Vicente Hernando:
> > Am Mittwoch, 13. Juni 2012, 15:47:59 schrieb Vicente Hernando:
> >> Looking into strstr man page: char *strstr(const char *haystack, const
> >> char *needle);
> >> 
> >> the patch advantage would be it already knows string lengths and has not
> >> to calculate them. Otherwise I expect strstr use a similar to Raita
> >> algoritm.
> > 
> > Hello Vincente,
> > 
> > in the past I replaced some internally re-implemented string functions
> > with
> > the ones from the glibc. So in my opinion we could do the same with this
> > function here, maybe add a small wrapper around it to not change the
> > signature.
> 
> I see using glibc functions as a good general approach.
> 
> Only doubt is when changing str strings into zero terminated strings,
> quickest way is adding '\0' at the end.
> 
> Is it always guaranteed to have enough space at the end of str.s to
> store '\0' value?

Hi Vincente,

good point, this is not guaranted and probably in many cases not the case. So 
the general library function is probably here not usable.

Best regards,

Henning



More information about the sr-dev mailing list