]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pack-objects.h
rebase --autosquash: fix a potential segfault
[thirdparty/git.git] / pack-objects.h
index feb6a6a05edba0772f4cfd8b4529bce9d3858751..3cd8d1f00a95978a5a8c86805506b9927aefcd0e 100644 (file)
@@ -5,6 +5,8 @@
 #include "thread-utils.h"
 #include "pack.h"
 
+struct repository;
+
 #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
 
 #define OE_DFS_STATE_BITS      2
@@ -127,6 +129,7 @@ struct object_entry {
 };
 
 struct packing_data {
+       struct repository *repo;
        struct object_entry *objects;
        uint32_t nr_objects, nr_alloc;
 
@@ -163,7 +166,7 @@ struct packing_data {
        unsigned char *layer;
 };
 
-void prepare_packing_data(struct packing_data *pdata);
+void prepare_packing_data(struct repository *r, struct packing_data *pdata);
 
 static inline void packing_data_lock(struct packing_data *pdata)
 {
@@ -412,7 +415,7 @@ static inline void oe_set_tree_depth(struct packing_data *pack,
                                     unsigned int tree_depth)
 {
        if (!pack->tree_depth)
-               ALLOC_ARRAY(pack->tree_depth, pack->nr_objects);
+               CALLOC_ARRAY(pack->tree_depth, pack->nr_alloc);
        pack->tree_depth[e - pack->objects] = tree_depth;
 }
 
@@ -429,7 +432,7 @@ static inline void oe_set_layer(struct packing_data *pack,
                                unsigned char layer)
 {
        if (!pack->layer)
-               ALLOC_ARRAY(pack->layer, pack->nr_objects);
+               CALLOC_ARRAY(pack->layer, pack->nr_alloc);
        pack->layer[e - pack->objects] = layer;
 }