current cvs segfault on Debian hppa

Eric Seppanen eds at reric.net
Thu Oct 3 19:59:11 CEST 2002


> I looked at this for a while last night... seems to me that combining 
> hmalloc calls is ok.  I suspect the problem is in combining xmalloc
> calls deeper down, especially calling for more than you need and saving
> some for later.

Yes, that's what I meant.  However, it's not always the case that calling 
xyzmalloc(a+b+c) will be safe, for example if 'a' and 'c' are sizes 
of structs and 'b' is the size of a string...  so we need to be very 
careful not to let this sneak in later.

> There is no need to wrap malloc/xmalloc this way.  The
> malloc routine already avoids calling sbrk (or whatever syscall is down
> there for your machine) which is the *real* expensive part.  If you only
> malloc what you can immediately use, you don't have to worry about align-
> ment at all.  Then...
> 
> p = malloc(sizeof(struct foo) + n + m);
> 
> Where n and m are byte buffer sizes should be portable and is indeed
> more efficient.

OK, if there's no performance hit I really think we should do that.  It'd 
be nice to ditch all that code wrapping xmalloc.



More information about the bogofilter-dev mailing list