Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 1 | #ifndef OBJECT_H |
| 2 | #define OBJECT_H |
| 3 | |
| 4 | struct object_list { |
| 5 | struct object *item; |
| 6 | struct object_list *next; |
Linus Torvalds | 9ce43d1 | 2005-06-26 15:26:05 -0700 | [diff] [blame] | 7 | const char *name; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 8 | }; |
| 9 | |
Junio C Hamano | 27dedf0 | 2005-11-16 21:32:44 -0800 | [diff] [blame] | 10 | struct object_refs { |
| 11 | unsigned count; |
Junio C Hamano | 8f1d2e6 | 2006-01-07 01:33:54 -0800 | [diff] [blame] | 12 | struct object *ref[FLEX_ARRAY]; /* more */ |
Junio C Hamano | 27dedf0 | 2005-11-16 21:32:44 -0800 | [diff] [blame] | 13 | }; |
| 14 | |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 15 | struct object { |
| 16 | unsigned parsed : 1; |
| 17 | unsigned used : 1; |
| 18 | unsigned int flags; |
| 19 | unsigned char sha1[20]; |
| 20 | const char *type; |
Junio C Hamano | 27dedf0 | 2005-11-16 21:32:44 -0800 | [diff] [blame] | 21 | struct object_refs *refs; |
jon@blackcubes.dyndns.org | a3437b8 | 2005-06-06 15:39:40 +0000 | [diff] [blame] | 22 | void *util; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 23 | }; |
| 24 | |
Linus Torvalds | 8805cca | 2005-09-16 14:55:33 -0700 | [diff] [blame] | 25 | extern int track_object_refs; |
Johannes Schindelin | 070879c | 2006-02-12 02:57:57 +0100 | [diff] [blame] | 26 | extern int obj_allocs; |
Petr Baudis | 8835504 | 2005-05-11 00:58:16 +0200 | [diff] [blame] | 27 | extern struct object **objs; |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 28 | |
Daniel Barkalow | 89e4202 | 2005-06-21 20:35:10 -0400 | [diff] [blame] | 29 | /** Internal only **/ |
Jason McMullan | 5d6ccf5 | 2005-06-03 11:05:39 -0400 | [diff] [blame] | 30 | struct object *lookup_object(const unsigned char *sha1); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 31 | |
Daniel Barkalow | 89e4202 | 2005-06-21 20:35:10 -0400 | [diff] [blame] | 32 | /** Returns the object, having looked it up as being the given type. **/ |
| 33 | struct object *lookup_object_type(const unsigned char *sha1, const char *type); |
| 34 | |
Jason McMullan | 5d6ccf5 | 2005-06-03 11:05:39 -0400 | [diff] [blame] | 35 | void created_object(const unsigned char *sha1, struct object *obj); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 36 | |
Daniel Barkalow | e9eefa6 | 2005-04-28 07:46:33 -0700 | [diff] [blame] | 37 | /** Returns the object, having parsed it to find out what it is. **/ |
Jason McMullan | 5d6ccf5 | 2005-06-03 11:05:39 -0400 | [diff] [blame] | 38 | struct object *parse_object(const unsigned char *sha1); |
Daniel Barkalow | e9eefa6 | 2005-04-28 07:46:33 -0700 | [diff] [blame] | 39 | |
barkalow@iabervon.org | 66e481b | 2005-08-02 19:45:48 -0400 | [diff] [blame] | 40 | /** Returns the object, with potentially excess memory allocated. **/ |
| 41 | struct object *lookup_unknown_object(const unsigned char *sha1); |
| 42 | |
Junio C Hamano | 27dedf0 | 2005-11-16 21:32:44 -0800 | [diff] [blame] | 43 | struct object_refs *alloc_object_refs(unsigned count); |
| 44 | void set_object_refs(struct object *obj, struct object_refs *refs); |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 45 | |
| 46 | void mark_reachable(struct object *obj, unsigned int mask); |
| 47 | |
barkalow@iabervon.org | 66e481b | 2005-08-02 19:45:48 -0400 | [diff] [blame] | 48 | struct object_list *object_list_insert(struct object *item, |
| 49 | struct object_list **list_p); |
| 50 | |
Daniel Barkalow | 680bab3 | 2005-09-05 02:04:18 -0400 | [diff] [blame] | 51 | void object_list_append(struct object *item, |
| 52 | struct object_list **list_p); |
| 53 | |
barkalow@iabervon.org | 66e481b | 2005-08-02 19:45:48 -0400 | [diff] [blame] | 54 | unsigned object_list_length(struct object_list *list); |
| 55 | |
| 56 | int object_list_contains(struct object_list *list, struct object *obj); |
| 57 | |
Daniel Barkalow | 6eb8ae0 | 2005-04-18 11:39:48 -0700 | [diff] [blame] | 58 | #endif /* OBJECT_H */ |