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

Re: where has ber_bvdup() gone?



>>>>> "Kurt" == Kurt D Zeilenga <Kurt@OpenLDAP.org> writes:

> At 03:35 PM 2002-01-05, Howard Chu wrote:
>>> -----Original Message-----
>>> From: Ganesan R <rganesan-ldap@myrealbox.com>
>> 
>>> I note that one of the reasons that strings are copied out of
>>> the BER data is to null terminate them.  A properly designed
>>> API would return pointers and length to non-null terminated
>>> strings, yet provide routines for converting to null terminating
>>> strings when applications desire such.
>> 
>> That's not strictly necessary. All the work can be done in-place
>> with some minor changes - in ber_get_next, the ber_buf should
>> be allocated with size ber_len+1 instead of ber_len, to allow
>> null-termination of the last element. Every preceding element can
>> be null-terminated by overwriting the following tag.

> doesn't work if the string is the last element of data...
> (you might be able to work around this by overallocating
> the BerElement with an extra octet.

OpenSLP (www.openslp.org) does null-termination exactly like this. Though
it's a much smaller project in scope than OpenLDAP to make a reasonable
comparison, the frugal use of malloc is excellent.

Ganesan