tdb2: allow multiple chain locks.
[ccan] / ccan / tdb2 / tdb.c
index 1dbbb7e93bdf46c16e8200abb9b5e0b3b3a885f4..18cf2e93a598ea7c3f742bcb3e445a5985686d55 100644 (file)
@@ -38,7 +38,7 @@ static enum TDB_ERROR replace_data(struct tdb_context *tdb,
 
        /* We didn't like the existing one: remove it. */
        if (old_off) {
 
        /* We didn't like the existing one: remove it. */
        if (old_off) {
-               add_stat(tdb, frees, 1);
+               tdb->stats.frees++;
                ecode = add_free_record(tdb, old_off,
                                        sizeof(struct tdb_used_record)
                                        + key.dsize + old_room);
                ecode = add_free_record(tdb, old_off,
                                        sizeof(struct tdb_used_record)
                                        + key.dsize + old_room);
@@ -285,7 +285,7 @@ enum TDB_ERROR tdb_delete(struct tdb_context *tdb, struct tdb_data key)
        }
 
        /* Free the deleted entry. */
        }
 
        /* Free the deleted entry. */
-       add_stat(tdb, frees, 1);
+       tdb->stats.frees++;
        ecode = add_free_record(tdb, off,
                                sizeof(struct tdb_used_record)
                                + rec_key_length(&rec)
        ecode = add_free_record(tdb, off,
                                sizeof(struct tdb_used_record)
                                + rec_key_length(&rec)
@@ -398,7 +398,7 @@ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
        /* tdb_open paths care about errno, so save it. */
        int saved_errno = errno;
 
        /* tdb_open paths care about errno, so save it. */
        int saved_errno = errno;
 
-       if (!tdb->logfn)
+       if (!tdb->log_fn)
                return ecode;
 
        va_start(ap, fmt);
                return ecode;
 
        va_start(ap, fmt);
@@ -406,11 +406,11 @@ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
        va_end(ap);
 
        if (len < 0) {
        va_end(ap);
 
        if (len < 0) {
-               tdb->logfn(tdb, TDB_LOG_ERROR, tdb->log_private,
-                          "out of memory formatting message:");
-               tdb->logfn(tdb, level, tdb->log_private, fmt);
+               tdb->log_fn(tdb, TDB_LOG_ERROR,
+                           "out of memory formatting message:", tdb->log_data);
+               tdb->log_fn(tdb, level, fmt, tdb->log_data);
        } else {
        } else {
-               tdb->logfn(tdb, level, tdb->log_private, message);
+               tdb->log_fn(tdb, level, message, tdb->log_data);
                free(message);
        }
        errno = saved_errno;
                free(message);
        }
        errno = saved_errno;
@@ -419,10 +419,10 @@ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
 
 enum TDB_ERROR tdb_parse_record_(struct tdb_context *tdb,
                                 TDB_DATA key,
 
 enum TDB_ERROR tdb_parse_record_(struct tdb_context *tdb,
                                 TDB_DATA key,
-                                enum TDB_ERROR (*parse)(TDB_DATA key,
-                                                        TDB_DATA data,
-                                                        void *p),
-                                void *p)
+                                enum TDB_ERROR (*parse)(TDB_DATA k,
+                                                        TDB_DATA d,
+                                                        void *data),
+                                void *data)
 {
        tdb_off_t off;
        struct tdb_used_record rec;
 {
        tdb_off_t off;
        struct tdb_used_record rec;
@@ -443,9 +443,9 @@ enum TDB_ERROR tdb_parse_record_(struct tdb_context *tdb,
                if (TDB_PTR_IS_ERR(dptr)) {
                        ecode = TDB_PTR_ERR(dptr);
                } else {
                if (TDB_PTR_IS_ERR(dptr)) {
                        ecode = TDB_PTR_ERR(dptr);
                } else {
-                       TDB_DATA data = tdb_mkdata(dptr, rec_data_length(&rec));
+                       TDB_DATA d = tdb_mkdata(dptr, rec_data_length(&rec));
 
 
-                       ecode = parse(key, data, p);
+                       ecode = parse(key, d, data);
                        tdb_access_release(tdb, dptr);
                }
        }
                        tdb_access_release(tdb, dptr);
                }
        }