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

Re: ldap_search_s



Well, if you use the iterators then they return a NULL.  The search
function itself does not.

Tom

On Mon, 3 Apr 2000, Randy Kunkee wrote:

> Interesting.  I'm sure I have some code where I set my message pointer to
> a NULL, and assume that if it is non-NULL, that I must free it.  This was
> easier than trying to keep track of where it failed.  This tells me I have
> a problem.
> 
> > 
> > I answered this question for myself.  It is "NO."
> > 
> > Tom
> > 
> > On Mon, 3 Apr 2000 tkaczma@gryf.net wrote:
> > 
> > > 
> > > Thanks, this makes more sense.  Can I expect the pointer to have it's
> > > original value after the search function is called if the search yields no
> > > results?
> > > 
> > > Tom
> > > 
> > > On Sat, 1 Apr 2000, Randy Kunkee wrote:
> > > 
> > > > > 
> > > > > Why does ldap_search_s take LDAPMessage ** as one of the arguments?
> > > > > 
> > > > > >From what I see only one LDAPMessage is ever returned.  It a bit confusing
> > > > > as LDAPMessage implies that it is a linked list.  Can someone explain to
> > > > > me why a doble pointer is necessary?
> > > > > 
> > > > > Thanks;
> > > > > Tom
> > > > > 
> > > > > 
> > > > 
> > > > The return value of ldap_search_s is LDAP_SUCCESS, or an error code.
> > > > The LDAP client library allocates memory, needs to return a pointer
> > > > to that message.  Since the status of the search is being returned
> > > > by the function, the pointer to result message structure must be
> > > > returned some other way.  Since what is being returned is an LDAPMessage *,
> > > > a pointer to that kind of memory is an LDAPMessage **.
> > > > 
> > > > By the way, you must free this when you are finished with it using
> > > > ldap_msgfree.
> > > > 
> > > > Example of usage would be:
> > > > 
> > > >    int resCode;
> > > >    LDAPMessage *ldapResultMessage; /* will point to the result */
> > > >    .
> > > >    .
> > > >    resCode = ldap_search_s(.... , &ldapResultMessage);
> > > >    if (resCode == LDAP_SUCCESS) {
> > > > 	.
> > > > 	.
> > > > 	ldap_msgfree(ldapResultMessage);
> > > >    } else {
> > > > 	/* print error */
> > > >    }
> > > > 
> > > > 
> > > > Regards,
> > > > Randy
> > > > 
> > > 
> > 
> > 
>