shallow.c: rename fields in paint_info to better express their purposes

paint_alloc() is basically malloc(), tuned for allocating a fixed number of bits on every call without worrying about freeing any individual allocation since all will be freed at the end. It does it by allocating a big block of memory every time it runs out of "free memory". "slab" is a poor choice of name, at least poorer than "pool". Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Dec 6, 2016 at 19:53 UTC 0afd307ab403404f7cf775fc5042f527e8289980
1 file changed +9 -9
shallow.c
+9 -9
@@ -356,9 +356,9 @@ define_commit_slab(ref_bitmap, uint32_t *);
356 struct paint_info {
357 struct ref_bitmap ref_bitmap;
358 unsigned nr_bits;
359 - char **slab;
359 + char **pools;
360 char *free, *end;
361 - unsigned slab_count;
361 + unsigned pool_count;
362 };
363
364 static uint32_t *paint_alloc(struct paint_info *info)
@@ -366,11 +366,11 @@ static uint32_t *paint_alloc(struct paint_info *info)
366 unsigned nr = (info->nr_bits + 31) / 32;
367 unsigned size = nr * sizeof(uint32_t);
368 void *p;
369 - if (!info->slab_count || info->free + size > info->end) {
370 - info->slab_count++;
371 - REALLOC_ARRAY(info->slab, info->slab_count);
369 + if (!info->pool_count || info->free + size > info->end) {
370 + info->pool_count++;
371 + REALLOC_ARRAY(info->pools, info->pool_count);
372 info->free = xmalloc(COMMIT_SLAB_SIZE);
373 - info->slab[info->slab_count - 1] = info->free;
373 + info->pools[info->pool_count - 1] = info->free;
374 info->end = info->free + COMMIT_SLAB_SIZE;
375 }
376 p = info->free;
@@ -546,9 +546,9 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
546 post_assign_shallow(info, &pi.ref_bitmap, ref_status);
547
548 clear_ref_bitmap(&pi.ref_bitmap);
549 - for (i = 0; i < pi.slab_count; i++)
550 - free(pi.slab[i]);
551 - free(pi.slab);
549 + for (i = 0; i < pi.pool_count; i++)
550 + free(pi.pools[i]);
551 + free(pi.pools);
552 free(shallow);
553 }
554