]> git.ipfire.org Git - thirdparty/git.git/blame - decorate.h
Merge branch 'jt/delay-fetch-if-missing'
[thirdparty/git.git] / decorate.h
CommitLineData
a59b276e
LT
1#ifndef DECORATE_H
2#define DECORATE_H
3
ddd3e312
JT
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 */
9
10/*
11 * An entry in the data structure.
12 */
13struct decoration_entry {
54988bda 14 const struct object *base;
a59b276e
LT
15 void *decoration;
16};
17
ddd3e312
JT
18/*
19 * The data structure.
20 *
21 * This data structure must be zero-initialized.
22 */
a59b276e 23struct decoration {
ddd3e312
JT
24 /*
25 * Not used by the decoration mechanism. Clients may use this for
26 * whatever they want.
27 */
a59b276e 28 const char *name;
ddd3e312
JT
29
30 /*
31 * The capacity of "entries".
32 */
33 unsigned int size;
34
35 /*
36 * The number of real Git objects (that is, entries with non-NULL
37 * "base").
38 */
39 unsigned int nr;
40
41 /*
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".
44 */
45 struct decoration_entry *entries;
a59b276e
LT
46};
47
ddd3e312
JT
48/*
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.
52 */
55454427 53void *add_decoration(struct decoration *n, const struct object *obj, void *decoration);
ddd3e312
JT
54
55/*
56 * Return the pointer associated to the given object. If there is no
57 * association, this function returns NULL.
58 */
55454427 59void *lookup_decoration(struct decoration *n, const struct object *obj);
a59b276e
LT
60
61#endif