- int rc;
- BerElement *ber;
- Entry *e;
- ber_tag_t tag;
- ber_len_t len;
- char *last;
-
- Debug( LDAP_DEBUG_TRACE, "=> entry_decode",
- 0, 0, 0 );
-
- ber = ber_init( bv );
- if( ber == NULL ) {
- Debug( LDAP_DEBUG_TRACE,
- "<= entry_encode: ber_init failed\n",
- 0, 0, 0 );
- return LDAP_LOCAL_ERROR;
- }
-
- /* initialize reader/writer lock */
- e = (Entry *) ch_malloc( sizeof(Entry) );
-
- if( e == NULL ) {
- Debug( LDAP_DEBUG_TRACE,
- "<= entry_encode: entry allocation failed\n",
- 0, 0, 0 );
- return LDAP_LOCAL_ERROR;
+ int siz = sizeof(Entry);
+ int len, dnlen, ndnlen;
+ int i, j;
+ Entry *f;
+ Attribute *a, *b;
+ struct berval **bvl, *bz;
+ char *ptr, *base, *data;
+
+ *bv = ch_malloc(sizeof(struct berval));
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
+ "entry_encode: id: 0x%08lx \"%s\"\n",
+ (long) e->e_id, e->e_dn ));
+#else
+ Debug( LDAP_DEBUG_TRACE, "=> entry_encode(0x%08lx): %s\n",
+ (long) e->e_id, e->e_dn, 0 );
+#endif
+ dnlen = strlen(e->e_dn);
+ ndnlen = strlen(e->e_ndn);
+ len = dnlen + ndnlen + 2; /* two trailing NUL bytes */
+ for (a=e->e_attrs; a; a=a->a_next) {
+ /* For AttributeDesc, we only store the attr name */
+ siz += sizeof(Attribute);
+ len += a->a_desc->ad_cname.bv_len+1;
+ for (i=0; a->a_vals[i]; i++) {
+ siz += sizeof(struct berval *);
+ siz += sizeof(struct berval);
+ len += a->a_vals[i]->bv_len + 1;
+ }
+ siz += sizeof(struct berval *); /* NULL pointer at end */