Sixth batch
[git.git] / commit-slab.h
blob69bf0c807c64b79216118f3485cfd5dac3b6a273
1 #ifndef COMMIT_SLAB_H
2 #define COMMIT_SLAB_H
4 #include "commit-slab-decl.h"
5 #include "commit-slab-impl.h"
7 /*
8 * define_commit_slab(slabname, elemtype) creates boilerplate code to define
9 * a new struct (struct slabname) that is used to associate a piece of data
10 * of elemtype to commits, and a few functions to use that struct.
12 * After including this header file, using:
14 * define_commit_slab(indegree, int);
16 * will let you call the following functions:
18 * - int *indegree_at(struct indegree *, struct commit *);
20 * This function locates the data associated with the given commit in
21 * the indegree slab, and returns the pointer to it. The location to
22 * store the data is allocated as necessary.
24 * - int *indegree_peek(struct indegree *, struct commit *);
26 * This function is similar to indegree_at(), but it will return NULL
27 * until a call to indegree_at() was made for the commit.
29 * - void init_indegree(struct indegree *);
30 * void init_indegree_with_stride(struct indegree *, int);
32 * Initializes the indegree slab that associates an array of integers
33 * to each commit. 'stride' specifies how big each array is. The slab
34 * that is initialized by the variant without "_with_stride" associates
35 * each commit with an array of one integer.
37 * - void clear_indegree(struct indegree *);
39 * Empties the slab. The slab can be reused with the same stride
40 * without calling init_indegree() again or can be reconfigured to a
41 * different stride by calling init_indegree_with_stride().
43 * Call this function before the slab falls out of scope to avoid
44 * leaking memory.
47 #define define_commit_slab(slabname, elemtype) \
48 declare_commit_slab(slabname, elemtype); \
49 implement_static_commit_slab(slabname, elemtype)
51 #endif /* COMMIT_SLAB_H */