Re: Do I need to ldap_memfree after ldap_get_lderrno? SDK docs say yes.
Rich Megginson <[email protected]> Thu, 27 Aug 2009 08:42:47 -0600
| Newsgroups | gmane.comp.mozilla.devel.directory |
|---|---|
| Message-ID | <[email protected]> |
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?
> - Can I pass NULL for either/both *m and *s? The SDK documentation
> doesn't explain whether I can pass NULL for a string I don't want.
Yes - see above.
> - Will I get LDAP_SUCCESS if there is no "last" error?
I'm not sure. Typical usage is that you only call ldap_get_lderrno if
some LDAP API function returned a value other than LDAP_SUCCESS.
>
> Thanks!
> - Matthew
>