tdb2: rename internal hashfn and logfn to hash_fn and log_fn.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 7 Apr 2011 05:35:58 +0000 (15:05 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 7 Apr 2011 05:35:58 +0000 (15:05 +0930)
We use underscores everywhere else, so be consistent.

ccan/tdb2/hash.c
ccan/tdb2/open.c
ccan/tdb2/private.h
ccan/tdb2/tdb.c
ccan/tdb2/test/run-001-encode.c

index b1307d985bef413edc2ebea3bb0fe2eaec4e16b0..c0b34f8a42ab576da4981cbf6b224c69f541bc35 100644 (file)
@@ -31,12 +31,12 @@ static uint64_t jenkins_hash(const void *key, size_t length, uint64_t seed,
 
 void tdb_hash_init(struct tdb_context *tdb)
 {
-       tdb->hashfn = jenkins_hash;
+       tdb->hash_fn = jenkins_hash;
 }
 
 uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len)
 {
-       return tdb->hashfn(ptr, len, tdb->hash_seed, tdb->hash_data);
+       return tdb->hash_fn(ptr, len, tdb->hash_seed, tdb->hash_data);
 }
 
 uint64_t hash_record(struct tdb_context *tdb, tdb_off_t off)
index a26148fc80d46cb9ee160a2e94b4bb857138917d..56514ae533a4c925635e5df350ad690bff34710d 100644 (file)
@@ -101,10 +101,10 @@ static enum TDB_ERROR tdb_new_database(struct tdb_context *tdb,
        else
                newdb.hdr.hash_seed = random_number(tdb);
        newdb.hdr.hash_test = TDB_HASH_MAGIC;
-       newdb.hdr.hash_test = tdb->hashfn(&newdb.hdr.hash_test,
-                                         sizeof(newdb.hdr.hash_test),
-                                         newdb.hdr.hash_seed,
-                                         tdb->hash_data);
+       newdb.hdr.hash_test = tdb->hash_fn(&newdb.hdr.hash_test,
+                                          sizeof(newdb.hdr.hash_test),
+                                          newdb.hdr.hash_seed,
+                                          tdb->hash_data);
        newdb.hdr.recovery = 0;
        newdb.hdr.features_used = newdb.hdr.features_offered = TDB_FEATURE_MASK;
        newdb.hdr.seqnum = 0;
@@ -205,7 +205,7 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
        tdb->name = NULL;
        tdb->direct_access = 0;
        tdb->flags = tdb_flags;
-       tdb->logfn = NULL;
+       tdb->log_fn = NULL;
        tdb->transaction = NULL;
        tdb->stats = NULL;
        tdb->access = NULL;
@@ -217,11 +217,11 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
        while (attr) {
                switch (attr->base.attr) {
                case TDB_ATTRIBUTE_LOG:
-                       tdb->logfn = attr->log.fn;
+                       tdb->log_fn = attr->log.fn;
                        tdb->log_data = attr->log.data;
                        break;
                case TDB_ATTRIBUTE_HASH:
-                       tdb->hashfn = attr->hash.fn;
+                       tdb->hash_fn = attr->hash.fn;
                        tdb->hash_data = attr->hash.data;
                        break;
                case TDB_ATTRIBUTE_SEED:
index ab9dc35f76f3a15cb1e7a4716e9ef56359c4711f..1309ce16c0a14c79bc67ee2192696dc4033b0c80 100644 (file)
@@ -365,14 +365,14 @@ struct tdb_context {
        uint32_t flags;
 
        /* Logging function */
-       void (*logfn)(struct tdb_context *tdb,
-                     enum tdb_log_level level,
-                     void *data,
-                     const char *message);
+       void (*log_fn)(struct tdb_context *tdb,
+                      enum tdb_log_level level,
+                      void *data,
+                      const char *message);
        void *log_data;
 
        /* Hash function. */
-       uint64_t (*hashfn)(const void *key, size_t len, uint64_t seed, void *);
+       uint64_t (*hash_fn)(const void *key, size_t len, uint64_t seed, void *);
        void *hash_data;
        uint64_t hash_seed;
 
index 01e77733f86c27fd84c438b6b2a1ee51f4b200ab..0fbe90f60996104cedd738a026d0b19599445361 100644 (file)
@@ -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;
 
-       if (!tdb->logfn)
+       if (!tdb->log_fn)
                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) {
-               tdb->logfn(tdb, TDB_LOG_ERROR, tdb->log_data,
-                          "out of memory formatting message:");
-               tdb->logfn(tdb, level, tdb->log_data, fmt);
+               tdb->log_fn(tdb, TDB_LOG_ERROR, tdb->log_data,
+                           "out of memory formatting message:");
+               tdb->log_fn(tdb, level, tdb->log_data, fmt);
        } else {
-               tdb->logfn(tdb, level, tdb->log_data, message);
+               tdb->log_fn(tdb, level, tdb->log_data, message);
                free(message);
        }
        errno = saved_errno;
index bfc9400daf830aca1a232e39dc5d62f9891c98f7..ffa4b93c02f7d2834e9bf51dc929f2ef427093b6 100644 (file)
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
 {
        unsigned int i;
        struct tdb_used_record rec;
-       struct tdb_context tdb = { .logfn = tap_log_fn };
+       struct tdb_context tdb = { .log_fn = tap_log_fn };
 
        plan_tests(64 + 32 + 48*6 + 1);