Exemple #1
0
void tommy_arrayblk_grow(tommy_arrayblk* array, unsigned size)
{
	unsigned block_max = (size + TOMMY_ARRAYBLK_SIZE - 1) / TOMMY_ARRAYBLK_SIZE;
	unsigned block_mac = tommy_array_size(&array->block);

	if (block_mac < block_max) {
		/* grow the block array */
		tommy_array_grow(&array->block, block_max);

		/* allocate new blocks */
		while (block_mac < block_max) {
			void* ptr = tommy_malloc(TOMMY_ARRAYBLK_SIZE * sizeof(void*));

			/* initializes it with zeros */
			memset(ptr, 0, TOMMY_ARRAYBLK_SIZE * sizeof(void*));

			/* set the new block */
			tommy_array_set(&array->block, block_mac, ptr);

			++block_mac;
		}
	}

	if (array->size < size)
		array->size = size;
}
Exemple #2
0
void tommy_arrayblk_done(tommy_arrayblk* array)
{
	unsigned i;

	for(i=0;i<tommy_array_size(&array->block);++i)
		tommy_free(tommy_array_get(&array->block, i));

	tommy_array_done(&array->block);
}
Exemple #3
0
static void crcache_free (cr_cache_t *cache) {
  uint32_t size;
  uint32_t i;

  if (cache != NULL) {
    size = tommy_array_size (cache->crates);
    for (i=0;i<size;i++) {
      free (crcache_read (cache,i));
    }
    tommy_array_done (cache->crates);
    free (cache->crates);
    free (cache);
  }
  return;
}
Exemple #4
0
tommy_size_t tommy_arrayblk_memory_usage(tommy_arrayblk* array)
{
	return tommy_array_memory_usage(&array->block) + tommy_array_size(&array->block) * TOMMY_ARRAYBLK_SIZE * sizeof(void*);
}