alloc: add repository argument to alloc_blob_node

This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. Use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed May 8, 2018 at 12:37 UTC f0de1d62ae5982630cfb2c713ddcda853b9ee0cf
3 files changed +4 -3
alloc.c
+1 -1
@@ -49,7 +49,7 @@ static inline void *alloc_node(struct alloc_state *s, size_t node_size)
49 }
50
51 static struct alloc_state blob_state;
52 -void *alloc_blob_node(void)
52 +void *alloc_blob_node_the_repository(void)
53 {
54 struct blob *b = alloc_node(&blob_state, sizeof(struct blob));
55 b->object.type = OBJ_BLOB;
blob.c
+1 -1
@@ -9,7 +9,7 @@ struct blob *lookup_blob(const struct object_id *oid)
9 struct object *obj = lookup_object(oid->hash);
10 if (!obj)
11 return create_object(the_repository, oid->hash,
12 - alloc_blob_node());
12 + alloc_blob_node(the_repository));
13 return object_as_type(obj, OBJ_BLOB, 0);
14 }
15
cache.h
+2 -1
@@ -1764,7 +1764,8 @@ int decode_85(char *dst, const char *line, int linelen);
1764 void encode_85(char *buf, const unsigned char *data, int bytes);
1765
1766 /* alloc.c */
1767 -extern void *alloc_blob_node(void);
1767 +#define alloc_blob_node(r) alloc_blob_node_##r()
1768 +extern void *alloc_blob_node_the_repository(void);
1769 extern void *alloc_tree_node(void);
1770 extern void *alloc_commit_node(void);
1771 extern void *alloc_tag_node(void);