quanah / net-ldapapi

The Net::LDAPapi Perl Module uses the OpenLDAP and Mozilla C api's to directly access and manipulate an LDAP v2 or LDAP v3 server.
8 stars 6 forks source link

Clarification of msgfree when used with next_changed_entries in doc #54

Open macrotex opened 4 years ago

macrotex commented 4 years ago

I would suggest you add the call to msgfree to the code fragment in the documentation for next_changed_entries. I had the msgfree OUTSIDE the loop because I was worried that msgfree would mess up the ldap object's listening. To avoid other users making that sort of mistake in the future, adding the msgfree call in the documentation for next_changed_entries would be helpful.

In other words, change this

   while(1) {
       while( @entries = $ld->next_changed_entries($msgid, 0, -1) ) {
           foreach $entry (@entries) {
               print "entry dn is <".$ld->get_dn($entry->{'entry'})."> ".
                   $entry->{'state'}."\n";
           }
       }
   }

to this

   while(1) {
       while( @entries = $ld->next_changed_entries($msgid, 0, -1) ) {
           foreach $entry (@entries) {
               print "entry dn is <".$ld->get_dn($entry->{'entry'})."> ".
                   $entry->{'state'}."\n";
           }
           $ld->msgfree();
       }
   }