/* $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
void
attrs_free( Attribute *a )
{
- Attribute *b;
+ Attribute *b, *tail, *next;
if ( a ) {
- for(b = a ; ; b = b->a_next ) {
- attr_clean( b );
- if ( !b->a_next )
- break;
- }
+ 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 );
- b->a_next = attr_list;
- attr_list = a;
+ tail->a_next = attr_list;
+ attr_list = b;
ldap_pvt_thread_mutex_unlock( &attr_mutex );
}
}
*nvalsp = nvals;
}
-error_return:;
if ( rc != LDAP_SUCCESS && nvals != NULL ) {
ber_bvarray_free_x( nvals, memctx );
}