]> git.ipfire.org Git - thirdparty/git.git/blob - commit-slab-decl.h
commit-slab.h: code split
[thirdparty/git.git] / commit-slab-decl.h
1 #ifndef COMMIT_SLAB_HDR_H
2 #define COMMIT_SLAB_HDR_H
3
4 /* allocate ~512kB at once, allowing for malloc overhead */
5 #ifndef COMMIT_SLAB_SIZE
6 #define COMMIT_SLAB_SIZE (512*1024-32)
7 #endif
8
9 #define declare_commit_slab(slabname, elemtype) \
10 \
11 struct slabname { \
12 unsigned slab_size; \
13 unsigned stride; \
14 unsigned slab_count; \
15 elemtype **slab; \
16 }
17
18 /*
19 * Statically initialize a commit slab named "var". Note that this
20 * evaluates "stride" multiple times! Example:
21 *
22 * struct indegree indegrees = COMMIT_SLAB_INIT(1, indegrees);
23 *
24 */
25 #define COMMIT_SLAB_INIT(stride, var) { \
26 COMMIT_SLAB_SIZE / sizeof(**((var).slab)) / (stride), \
27 (stride), 0, NULL \
28 }
29
30 #endif /* COMMIT_SLAB_HDR_H */