]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/attr.c
streamline group attr specification/diagnostics
[openldap] / servers / slapd / attr.c
index 3c397c64f294cd21e664060ff7ab9714231607b1..4e418e3032780459f670c8cb38414a108d76ab83 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -185,17 +185,23 @@ comp_tree_free( Attribute *a )
 void
 attrs_free( Attribute *a )
 {
-       Attribute *b;
-
-       for(b = a ; b != NULL ; b = b->a_next ) {
-               attr_clean( b );
-               if ( !b->a_next )
-                       break;
+       Attribute *b, *tail, *next;
+
+       if ( a ) {
+               tail = a;
+               do {
+                       next = a->a_next;
+                       attr_clean( a );
+                       a->a_next = b;
+                       b = a;
+                       a = next;
+               } while ( next );
+
+               ldap_pvt_thread_mutex_lock( &attr_mutex );
+               tail->a_next = attr_list;
+               attr_list = b;
+               ldap_pvt_thread_mutex_unlock( &attr_mutex );
        }
-       ldap_pvt_thread_mutex_lock( &attr_mutex );
-       b->a_next = attr_list;
-       attr_list = a;
-       ldap_pvt_thread_mutex_unlock( &attr_mutex );
 }
 
 static void
@@ -371,7 +377,6 @@ attr_normalize(
                *nvalsp = nvals;
        }
 
-error_return:;
        if ( rc != LDAP_SUCCESS && nvals != NULL ) {
                ber_bvarray_free_x( nvals, memctx );
        }