]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/ldapsync.c
Partial revert of f30269f5d2e4bb5ee7486fe6542078d1b59dba6d
[openldap] / servers / slapd / ldapsync.c
index d2e9f621b47f423add7c454066a64c45bdadcda8..bf20388477734109169b3484df70db46184dc068 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2011 The OpenLDAP Foundation.
+ * Copyright 2003-2012 The OpenLDAP Foundation.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
  *
@@ -169,16 +169,16 @@ slap_parse_csn_sids( BerVarray csns, int numcsns, void *memctx )
 static slap_mr_match_func sidsort_cmp;
 
 static const MatchingRule sidsort_mr = {
-       {},
+       { 0 },
        NULL,
-       {},
-       {},
+       { 0 },
+       { 0 },
        0,
        NULL, NULL, NULL, sidsort_cmp
 };
 static const AttributeType sidsort_at = {
-       {},
-       {},
+       { 0 },
+       { 0 },
        NULL, NULL, (MatchingRule *)&sidsort_mr,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, SLAP_AT_SORTED_VAL
 };
@@ -228,6 +228,28 @@ slap_sort_csn_sids( BerVarray csns, int *sids, int numcsns, void *memctx )
        return rc;
 }
 
+void
+slap_insert_csn_sids(
+       struct sync_cookie *ck,
+       int pos,
+       int sid,
+       struct berval *csn
+)
+{
+       int i;
+       ck->numcsns++;
+       ck->ctxcsn = ch_realloc( ck->ctxcsn,
+               (ck->numcsns+1) * sizeof(struct berval));
+       BER_BVZERO( &ck->ctxcsn[ck->numcsns] );
+       ck->sids = ch_realloc( ck->sids, ck->numcsns * sizeof(int));
+       for ( i = ck->numcsns-1; i > pos; i-- ) {
+               ck->ctxcsn[i] = ck->ctxcsn[i-1];
+               ck->sids[i] = ck->sids[i-1];
+       }
+       ck->sids[i] = sid;
+       ber_dupbv( &ck->ctxcsn[i], csn );
+}
+
 int
 slap_parse_sync_cookie(
        struct sync_cookie *cookie,