Re: Do I need to ldap_memfree after ldap_get_lderrno? SDK docs say yes.
"Matthew M. DeLoera" <[email protected]> Thu, 27 Aug 2009 10:48:00 -0400
| Newsgroups | gmane.comp.mozilla.devel.directory |
|---|---|
| Message-ID | <[email protected]> |
Rich Megginson wrote:
> Matthew M. DeLoera wrote:
>> Some basic questions about ldap_get_lderrno:
>>
>> - Do I have to call ldap_memfree for either *m or *s? Code example
>> 5-6 in the SDK documentation calls ldap_memfree to release the error
>> string after printing it. Do I have to call it for both?
>
> Eek - that's bad. You should not free those pointers. Here is the
> actual code:
> if ( m != NULL ) {
> *m = ld->ld_matched;
> }
> if ( s != NULL ) {
> *s = ld->ld_error;
> }
> return( ld->ld_errno );
>
> It returns pointers to the internal data structures - you should never
> call free on these pointers.
>
> Can you point me to the documentation you referred to?
Hi Rich! Yes - code example 5-6:
- Go to chapter 18 (function reference).
- Jump to ldap_get_lderrno().
- Jump to "Getting Information About the Error".
- Scroll down the page to Code Example 5-6. ldap_memfree() is being
called on the error message pointer.
Thanks for the summary of intent. That helps me a lot! :)
Regards,
- Matthew