summaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-07-07 21:56:11 -0700
committerVicent Marti <tanoku@gmail.com>2013-07-10 20:50:32 +0200
commit9abc78ae6157167682f061b4f73eea51ab7d7342 (patch)
treee037ab6838882697af78b930dcbf1da828943d3e /src/array.h
parentbc6f0839ebd5794c99d5b488d431188a162a064d (diff)
downloadlibgit2-9abc78ae6157167682f061b4f73eea51ab7d7342.tar.gz
Convert commit->parent_ids to git_array_t
This converts the array of parent SHAs from a git_vector where each SHA has to be separately allocated to a git_array_t where all the SHAs can be kept in one block. Since the two collections have almost identical APIs, there isn't much involved in making the change. I did add an API to git_array_t so that it could be allocated at a precise initial size.
Diffstat (limited to 'src/array.h')
-rw-r--r--src/array.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/array.h b/src/array.h
index 2d77c71a0..707570624 100644
--- a/src/array.h
+++ b/src/array.h
@@ -30,6 +30,9 @@
#define git_array_init(a) \
do { (a).size = (a).asize = 0; (a).ptr = NULL; } while (0)
+#define git_array_init_to_size(a, desired) \
+ do { (a).size = 0; (a).asize = desired; (a).ptr = git__calloc(desired, sizeof(*(a).ptr)); } while (0)
+
#define git_array_clear(a) \
do { git__free((a).ptr); git_array_init(a); } while (0)