[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: An optimization for another day (and developer)



> BTW, one optimization I intended to implement but haven't
> the time is to allow:
> 	struct berval bv = { 0, NULL }
> 	struct berval *bvp = &bv;
> 
> 	rc = dnPretty( NULL, &dn, &bvp );
> 	rc = dnNormalize( NULL, &dn, &bvp );
> 
> That is, allow call to provide, optionally, a
> pre-allocated struct berval instead of relying
> on the caller to malloc on up.  Of course, in
> some cases, the existing behavior is preferred.

I note that relying on developers (I speak mostly of myself :)
to supply a NULL pointer if alloc is required or non-NULL pointer
if it can be safely used is dangerous: no more than five minutes
ago I fixed this bug in back-monitor.  I'd rather use a alloc/use
flag in an ancillary function, or radically change the API
to accept only pre-allocated structs, which wouldn't be a big issue 
since the big allocation takes place for the bv_val, not for the 
struct berval.

Of course, by using appropriate safety checks and tools your
suggestion would provide an interesting optimization.

Ando.