|
|
|
@ -261,18 +261,32 @@ struct commit_buffer {
@@ -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)
@@ -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)
@@ -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) { |
|
|
|
|