diff options
author | Stefan Beller <sbeller@google.com> | 2018-06-28 18:22:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-06-29 10:43:40 -0700 |
commit | 65ea9d4bec141295d34955b286c32725fe3b422d (patch) | |
tree | 5a742e83896145560fcd1e7e2489589613191276 /commit.c | |
parent | commit-slabs: remove realloc counter outside of slab struct (diff) | |
download | tgif-65ea9d4bec141295d34955b286c32725fe3b422d.tar.xz |
commit.c: migrate the commit buffer to the parsed object store
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -261,18 +261,32 @@ struct commit_buffer { unsigned long size; }; define_commit_slab(buffer_slab, struct commit_buffer); -static struct buffer_slab buffer_slab = COMMIT_SLAB_INIT(1, buffer_slab); + +struct buffer_slab *allocate_commit_buffer_slab(void) +{ + struct buffer_slab *bs = xmalloc(sizeof(*bs)); + init_buffer_slab(bs); + return bs; +} + +void free_commit_buffer_slab(struct buffer_slab *bs) +{ + clear_buffer_slab(bs); + free(bs); +} void set_commit_buffer_the_repository(struct commit *commit, void *buffer, unsigned long size) { - struct commit_buffer *v = buffer_slab_at(&buffer_slab, commit); + struct commit_buffer *v = buffer_slab_at( + the_repository->parsed_objects->buffer_slab, commit); v->buffer = buffer; v->size = size; } const void *get_cached_commit_buffer_the_repository(const struct commit *commit, unsigned long *sizep) { - struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit); + struct commit_buffer *v = buffer_slab_peek( + the_repository->parsed_objects->buffer_slab, commit); if (!v) { if (sizep) *sizep = 0; @@ -304,14 +318,16 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep) void unuse_commit_buffer(const struct commit *commit, const void *buffer) { - struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit); + struct commit_buffer *v = buffer_slab_peek( + the_repository->parsed_objects->buffer_slab, commit); if (!(v && v->buffer == buffer)) free((void *)buffer); } void free_commit_buffer(struct commit *commit) { - struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit); + struct commit_buffer *v = buffer_slab_peek( + the_repository->parsed_objects->buffer_slab, commit); if (v) { FREE_AND_NULL(v->buffer); v->size = 0; @@ -347,7 +363,8 @@ void release_commit_memory(struct commit *c) const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep) { - struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit); + struct commit_buffer *v = buffer_slab_peek( + the_repository->parsed_objects->buffer_slab, commit); void *ret; if (!v) { |