commit: --amend -m '' silently fails to wipe message
[gitweb.git] / pack-bitmap.c
index 62a98cc119e3bf5a7b71e6b47143e06653ee9d6e..aee7acf39204178f605221e49c66d302ca5329aa 100644 (file)
@@ -209,14 +209,12 @@ static inline uint8_t read_u8(const unsigned char *buffer, size_t *pos)
        return buffer[(*pos)++];
 }
 
+#define MAX_XOR_OFFSET 160
+
 static int load_bitmap_entries_v1(struct bitmap_index *index)
 {
-       static const size_t MAX_XOR_OFFSET = 160;
-
        uint32_t i;
-       struct stored_bitmap **recent_bitmaps;
-
-       recent_bitmaps = xcalloc(MAX_XOR_OFFSET, sizeof(struct stored_bitmap));
+       struct stored_bitmap *recent_bitmaps[MAX_XOR_OFFSET] = { NULL };
 
        for (i = 0; i < index->entry_count; ++i) {
                int xor_offset, flags;
@@ -424,19 +422,15 @@ static int ext_index_add_object(struct object *object, const char *name)
        return bitmap_pos + bitmap_git.pack->num_objects;
 }
 
-static void show_object(struct object *object, const struct name_path *path,
-                       const char *last, void *data)
+static void show_object(struct object *object, const char *name, void *data)
 {
        struct bitmap *base = data;
        int bitmap_pos;
 
        bitmap_pos = bitmap_position(object->sha1);
 
-       if (bitmap_pos < 0) {
-               char *name = path_name(path, last);
+       if (bitmap_pos < 0)
                bitmap_pos = ext_index_add_object(object, name);
-               free(name);
-       }
 
        bitmap_set(base, bitmap_pos);
 }
@@ -624,7 +618,7 @@ static void show_objects_for_type(
        while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
                eword_t word = objects->words[i] & filter;
 
-               for (offset = 0; offset < BITS_IN_WORD; ++offset) {
+               for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
                        const unsigned char *sha1;
                        struct revindex_entry *entry;
                        uint32_t hash = 0;
@@ -646,7 +640,7 @@ static void show_objects_for_type(
                        show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
                }
 
-               pos += BITS_IN_WORD;
+               pos += BITS_IN_EWORD;
                i++;
        }
 }
@@ -778,7 +772,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile,
                        break;
                }
 
-               reuse_objects += BITS_IN_WORD;
+               reuse_objects += BITS_IN_EWORD;
        }
 
 #ifdef GIT_BITMAP_DEBUG
@@ -904,9 +898,8 @@ struct bitmap_test_data {
        size_t seen;
 };
 
-static void test_show_object(struct object *object,
-                            const struct name_path *path,
-                            const char *last, void *data)
+static void test_show_object(struct object *object, const char *name,
+                            void *data)
 {
        struct bitmap_test_data *tdata = data;
        int bitmap_pos;
@@ -987,7 +980,7 @@ void test_bitmap_walk(struct rev_info *revs)
        else
                fprintf(stderr, "Mismatch!\n");
 
-       free(result);
+       bitmap_free(result);
 }
 
 static int rebuild_bitmap(uint32_t *reposition,
@@ -1003,7 +996,7 @@ static int rebuild_bitmap(uint32_t *reposition,
        while (ewah_iterator_next(&word, &it)) {
                uint32_t offset, bit_pos;
 
-               for (offset = 0; offset < BITS_IN_WORD; ++offset) {
+               for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
                        if ((word >> offset) == 0)
                                break;
 
@@ -1016,7 +1009,7 @@ static int rebuild_bitmap(uint32_t *reposition,
                                return -1;
                }
 
-               pos += BITS_IN_WORD;
+               pos += BITS_IN_EWORD;
        }
        return 0;
 }