blob: e08afbd29ff04cf463a4aacdc4fe141a2ab54ce6 [file] [log] [blame]
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -07001#ifndef OBJECT_H
2#define OBJECT_H
3
4struct object_list {
5 struct object *item;
6 struct object_list *next;
Linus Torvalds9ce43d12005-06-26 15:26:05 -07007 const char *name;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -07008};
9
Junio C Hamano27dedf02005-11-16 21:32:44 -080010struct object_refs {
11 unsigned count;
Junio C Hamano8f1d2e62006-01-07 01:33:54 -080012 struct object *ref[FLEX_ARRAY]; /* more */
Junio C Hamano27dedf02005-11-16 21:32:44 -080013};
14
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070015struct object {
16 unsigned parsed : 1;
17 unsigned used : 1;
18 unsigned int flags;
19 unsigned char sha1[20];
20 const char *type;
Junio C Hamano27dedf02005-11-16 21:32:44 -080021 struct object_refs *refs;
jon@blackcubes.dyndns.orga3437b82005-06-06 15:39:40 +000022 void *util;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070023};
24
Linus Torvalds8805cca2005-09-16 14:55:33 -070025extern int track_object_refs;
Johannes Schindelin070879c2006-02-12 02:57:57 +010026extern int obj_allocs;
Petr Baudis88355042005-05-11 00:58:16 +020027extern struct object **objs;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070028
Daniel Barkalow89e42022005-06-21 20:35:10 -040029/** Internal only **/
Jason McMullan5d6ccf52005-06-03 11:05:39 -040030struct object *lookup_object(const unsigned char *sha1);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070031
Daniel Barkalow89e42022005-06-21 20:35:10 -040032/** Returns the object, having looked it up as being the given type. **/
33struct object *lookup_object_type(const unsigned char *sha1, const char *type);
34
Jason McMullan5d6ccf52005-06-03 11:05:39 -040035void created_object(const unsigned char *sha1, struct object *obj);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070036
Daniel Barkalowe9eefa62005-04-28 07:46:33 -070037/** Returns the object, having parsed it to find out what it is. **/
Jason McMullan5d6ccf52005-06-03 11:05:39 -040038struct object *parse_object(const unsigned char *sha1);
Daniel Barkalowe9eefa62005-04-28 07:46:33 -070039
barkalow@iabervon.org66e481b2005-08-02 19:45:48 -040040/** Returns the object, with potentially excess memory allocated. **/
41struct object *lookup_unknown_object(const unsigned char *sha1);
42
Junio C Hamano27dedf02005-11-16 21:32:44 -080043struct object_refs *alloc_object_refs(unsigned count);
44void set_object_refs(struct object *obj, struct object_refs *refs);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070045
46void mark_reachable(struct object *obj, unsigned int mask);
47
barkalow@iabervon.org66e481b2005-08-02 19:45:48 -040048struct object_list *object_list_insert(struct object *item,
49 struct object_list **list_p);
50
Daniel Barkalow680bab32005-09-05 02:04:18 -040051void object_list_append(struct object *item,
52 struct object_list **list_p);
53
barkalow@iabervon.org66e481b2005-08-02 19:45:48 -040054unsigned object_list_length(struct object_list *list);
55
56int object_list_contains(struct object_list *list, struct object *obj);
57
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070058#endif /* OBJECT_H */