Merge branch 'kg/external-diff-save-env'
[git.git] / decorate.h
blob9014c1e996c60d9b3e1bd27ffa01b9c2d0c8ae80
1 #ifndef DECORATE_H
2 #define DECORATE_H
4 /*
5 * A data structure that associates Git objects to void pointers. See
6 * t/helper/test-example-decorate.c for a demonstration of how to use these
7 * functions.
8 */
11 * An entry in the data structure.
13 struct decoration_entry {
14 const struct object *base;
15 void *decoration;
19 * The data structure.
21 * This data structure must be zero-initialized.
23 struct decoration {
25 * Not used by the decoration mechanism. Clients may use this for
26 * whatever they want.
28 const char *name;
31 * The capacity of "entries".
33 unsigned int size;
36 * The number of real Git objects (that is, entries with non-NULL
37 * "base").
39 unsigned int nr;
42 * The entries. This is an array of size "size", containing nr entries
43 * with non-NULL "base" and (size - nr) entries with NULL "base".
45 struct decoration_entry *entries;
49 * Add an association from the given object to the given pointer (which may be
50 * NULL), returning the previously associated pointer. If there is no previous
51 * association, this function returns NULL.
53 extern void *add_decoration(struct decoration *n, const struct object *obj, void *decoration);
56 * Return the pointer associated to the given object. If there is no
57 * association, this function returns NULL.
59 extern void *lookup_decoration(struct decoration *n, const struct object *obj);
61 #endif