1#ifndef OBJECT_H
2#define OBJECT_H
34
struct object_list {
5struct object *item;
6struct object_list *next;
7const char *name;
8};
910
struct object_refs {
11unsigned count;
12struct object *base;
13struct object *ref[FLEX_ARRAY]; /* more */
14};
1516
#define TYPE_BITS 3
17#define FLAG_BITS 27
1819
#define TYPE_NONE 0
20#define TYPE_BLOB 1
21#define TYPE_TREE 2
22#define TYPE_COMMIT 3
23#define TYPE_TAG 4
24#define TYPE_BAD 5
2526
struct object {
27unsigned parsed : 1;
28unsigned used : 1;
29unsigned type : TYPE_BITS;
30unsigned flags : FLAG_BITS;
31unsigned char sha1[20];
32};
3334
extern int track_object_refs;
35extern int obj_allocs;
36extern struct object **objs;
37extern const char *type_names[];
3839
static inline const char *typename(unsigned int type)
40{
41return type_names[type > TYPE_TAG ? TYPE_BAD : type];
42}
4344
extern struct object_refs *lookup_object_refs(struct object *);
4546
/** Internal only **/
47struct object *lookup_object(const unsigned char *sha1);
4849
/** Returns the object, having looked it up as being the given type. **/
50struct object *lookup_object_type(const unsigned char *sha1, const char *type);
5152
void created_object(const unsigned char *sha1, struct object *obj);
5354
/** Returns the object, having parsed it to find out what it is. **/
55struct object *parse_object(const unsigned char *sha1);
5657
/** Returns the object, with potentially excess memory allocated. **/
58struct object *lookup_unknown_object(const unsigned char *sha1);
5960
struct object_refs *alloc_object_refs(unsigned count);
61void set_object_refs(struct object *obj, struct object_refs *refs);
6263
void mark_reachable(struct object *obj, unsigned int mask);
6465
struct object_list *object_list_insert(struct object *item,
66struct object_list **list_p);
6768
void object_list_append(struct object *item,
69struct object_list **list_p);
7071
unsigned object_list_length(struct object_list *list);
7273
int object_list_contains(struct object_list *list, struct object *obj);
7475
#endif /* OBJECT_H */