f4ee2e55ba7853e3b49cbca7409c89b71d4b848f
   1#ifndef OBJECT_H
   2#define OBJECT_H
   3struct object_list {
   5        struct object *item;
   6        struct object_list *next;
   7        const char *name;
   8};
   9struct object_refs {
  11        unsigned count;
  12        struct object *ref[FLEX_ARRAY]; /* more */
  13};
  14#define TYPE_BITS   3
  16#define FLAG_BITS  27
  17#define TYPE_NONE   0
  19#define TYPE_BLOB   1
  20#define TYPE_TREE   2
  21#define TYPE_COMMIT 3
  22#define TYPE_TAG    4
  23#define TYPE_BAD    5
  24struct object {
  26        unsigned parsed : 1;
  27        unsigned used : 1;
  28        unsigned type : TYPE_BITS;
  29        unsigned flags : FLAG_BITS;
  30        unsigned char sha1[20];
  31        struct object_refs *refs;
  32};
  33extern int track_object_refs;
  35extern int obj_allocs;
  36extern struct object **objs;
  37extern const char *type_names[];
  38static inline const char *typename(unsigned int type)
  40{
  41        return type_names[type > TYPE_TAG ? TYPE_BAD : type];
  42}
  43/** Internal only **/
  45struct object *lookup_object(const unsigned char *sha1);
  46/** Returns the object, having looked it up as being the given type. **/
  48struct object *lookup_object_type(const unsigned char *sha1, const char *type);
  49void created_object(const unsigned char *sha1, struct object *obj);
  51/** Returns the object, having parsed it to find out what it is. **/
  53struct object *parse_object(const unsigned char *sha1);
  54/** Returns the object, with potentially excess memory allocated. **/
  56struct object *lookup_unknown_object(const unsigned  char *sha1);
  57struct object_refs *alloc_object_refs(unsigned count);
  59void set_object_refs(struct object *obj, struct object_refs *refs);
  60void mark_reachable(struct object *obj, unsigned int mask);
  62struct object_list *object_list_insert(struct object *item, 
  64                                       struct object_list **list_p);
  65void object_list_append(struct object *item,
  67                        struct object_list **list_p);
  68unsigned object_list_length(struct object_list *list);
  70int object_list_contains(struct object_list *list, struct object *obj);
  72#endif /* OBJECT_H */