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

Re: Why ldap_<first,next>_attribute ?



Ian Bruce writes:
>Mark Smith wrote:
>> I don't think there is any special reason why the
>> ldap_first/next_attribute() approach was used instead of just returning
>> an array.
> 
> How big did you make the array? Guess what, I want one more!

A malloced "array", hopefully.

> In general, a linked list is a better solution when the dimension of
> the array would be hard to quess and be safe.

Malloc rules!  You can guess first and realloc() afterwards.

> The only real downside is that
> you need to be careful to free the memory when you are done, (...)

LDAPAPI already has ldap_values_free() to free a malloced array of
null-terminated strings.

-- 
Hallvard