]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/io.c
tdb: fix test helper to include own header, fix function definition.
[ccan] / ccan / tdb / io.c
index ca7d0819b99d9db45aebb757b054106d3a1f1961..e56be6fa38362e9b8666f34deb43c38b80831a13 100644 (file)
@@ -194,7 +194,9 @@ int tdb_munmap(struct tdb_context *tdb)
 
 #if HAVE_MMAP
        if (tdb->map_ptr) {
 
 #if HAVE_MMAP
        if (tdb->map_ptr) {
-               int ret = munmap(tdb->map_ptr, tdb->map_size);
+               int ret;
+
+               ret = munmap(tdb->map_ptr, tdb->map_size);
                if (ret != 0)
                        return ret;
        }
                if (ret != 0)
                        return ret;
        }
@@ -298,7 +300,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
    file and doing the mmap again if necessary */
 int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
 {
    file and doing the mmap again if necessary */
 int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
 {
-       struct list_struct rec;
+       struct tdb_record rec;
        tdb_off_t offset, new_size;     
 
        if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
        tdb_off_t offset, new_size;     
 
        if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
@@ -386,6 +388,7 @@ unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len
        unsigned char *buf;
 
        /* some systems don't like zero length malloc */
        unsigned char *buf;
 
        /* some systems don't like zero length malloc */
+
        if (!(buf = (unsigned char *)malloc(len ? len : 1))) {
                /* Ensure ecode is set for log fn. */
                tdb->ecode = TDB_ERR_OOM;
        if (!(buf = (unsigned char *)malloc(len ? len : 1))) {
                /* Ensure ecode is set for log fn. */
                tdb->ecode = TDB_ERR_OOM;
@@ -435,7 +438,7 @@ int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key,
 }
 
 /* read/write a record */
 }
 
 /* read/write a record */
-int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
+int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec)
 {
        if (tdb->methods->tdb_read(tdb, offset, rec, sizeof(*rec),DOCONV()) == -1)
                return -1;
 {
        if (tdb->methods->tdb_read(tdb, offset, rec, sizeof(*rec),DOCONV()) == -1)
                return -1;
@@ -448,9 +451,9 @@ int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *
        return tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0);
 }
 
        return tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0);
 }
 
-int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec)
+int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec)
 {
 {
-       struct list_struct r = *rec;
+       struct tdb_record r = *rec;
        return tdb->methods->tdb_write(tdb, offset, CONVERT(r), sizeof(r));
 }
 
        return tdb->methods->tdb_write(tdb, offset, CONVERT(r), sizeof(r));
 }
 
@@ -460,8 +463,6 @@ static const struct tdb_methods io_methods = {
        tdb_next_hash_chain,
        tdb_oob,
        tdb_expand_file,
        tdb_next_hash_chain,
        tdb_oob,
        tdb_expand_file,
-       tdb_brlock,
-       tdb_brunlock
 };
 
 /*
 };
 
 /*