patches to merge string and charset code

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Apr 12 02:11:21 MDT 2011

Hi, Andrew!

On Tue, Apr 12, 2011 at 05:49:26PM +1000, Andrew Bartlett wrote:
> I've spent a fair bit of my day today working on a patch series to merge
> significant parts of our string code. 

One comment regarding for example c2cf3d3d57d3b: There I
find a call tmpbuf = strupper_talloc(NULL, passwd). For the
code paths that are called from source3 I would highly
recommend to use talloc_tos(). There are two important
advantages to using that:

First, it is better to avoid memory leaks. As far as I can
see this is not an issue with your current patch, but future
modifications might introduce other error paths where people
might forget to talloc_free(tmpbuf) properly. talloc_tos()
in s3 safely cleans up shortly after the routine was left.

Second, allocating from talloc_tos() in smbd3 in many cases
is faster, as we allocate from a talloc_pool. This comes
down to simply incrementing a pointer, in many cases (the
pool is not exhausted) it avoids calling the libc malloc.

So, when calling this in s3 code, please make sure that
instead of allocating temporary objects from a NULL pointer
or another long-living talloc context, please use

I know that we don't have this in all places in s3 yet, but
for code that is touched anyway we like to make sure that
this convention is held up.



SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen

More information about the samba-technical mailing list