commit-slab.h 1.78 KB
Newer Older
1 2 3
#ifndef COMMIT_SLAB_H
#define COMMIT_SLAB_H

Duy Nguyen's avatar
Duy Nguyen committed
4 5 6
#include "commit-slab-decl.h"
#include "commit-slab-impl.h"

7 8 9 10 11 12 13
/*
 * 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:
 *
Ville Skyttä's avatar
Ville Skyttä committed
14
 * define_commit_slab(indegree, int);
15 16 17 18 19 20
 *
 * 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
21 22 23 24 25 26 27
 *   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.
28 29 30 31 32 33
 *
 * - 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
34
 *   that is initialized by the variant without "_with_stride" associates
35
 *   each commit with an array of one integer.
36 37 38 39 40 41 42 43 44
 *
 * - 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.
45 46
 */

Duy Nguyen's avatar
Duy Nguyen committed
47 48
#define define_commit_slab(slabname, elemtype) \
	declare_commit_slab(slabname, elemtype); \
49
	implement_static_commit_slab(slabname, elemtype)
50

51
#endif /* COMMIT_SLAB_H */