diff options
author | Vincent Ambo <Vincent Ambo> | 2020-01-11T23·36+0000 |
---|---|---|
committer | Vincent Ambo <Vincent Ambo> | 2020-01-11T23·36+0000 |
commit | 1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 (patch) | |
tree | e3accb9beed5c4c1b5a05c99db71ab2841f0ed04 /commit-slab.h |
Squashed 'third_party/git/' content from commit cb71568594
git-subtree-dir: third_party/git git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7
Diffstat (limited to 'commit-slab.h')
-rw-r--r-- | commit-slab.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/commit-slab.h b/commit-slab.h new file mode 100644 index 000000000000..69bf0c807c64 --- /dev/null +++ b/commit-slab.h @@ -0,0 +1,51 @@ +#ifndef COMMIT_SLAB_H +#define COMMIT_SLAB_H + +#include "commit-slab-decl.h" +#include "commit-slab-impl.h" + +/* + * define_commit_slab(slabname, elemtype) creates boilerplate code to define + * a new struct (struct slabname) that is used to associate a piece of data + * of elemtype to commits, and a few functions to use that struct. + * + * After including this header file, using: + * + * define_commit_slab(indegree, int); + * + * will let you call the following functions: + * + * - int *indegree_at(struct indegree *, struct commit *); + * + * This function locates the data associated with the given commit in + * the indegree slab, and returns the pointer to it. The location to + * store the data is allocated as necessary. + * + * - int *indegree_peek(struct indegree *, struct commit *); + * + * This function is similar to indegree_at(), but it will return NULL + * until a call to indegree_at() was made for the commit. + * + * - void init_indegree(struct indegree *); + * void init_indegree_with_stride(struct indegree *, int); + * + * Initializes the indegree slab that associates an array of integers + * to each commit. 'stride' specifies how big each array is. The slab + * that is initialized by the variant without "_with_stride" associates + * each commit with an array of one integer. + * + * - void clear_indegree(struct indegree *); + * + * Empties the slab. The slab can be reused with the same stride + * without calling init_indegree() again or can be reconfigured to a + * different stride by calling init_indegree_with_stride(). + * + * Call this function before the slab falls out of scope to avoid + * leaking memory. + */ + +#define define_commit_slab(slabname, elemtype) \ + declare_commit_slab(slabname, elemtype); \ + implement_static_commit_slab(slabname, elemtype) + +#endif /* COMMIT_SLAB_H */ |