Esempio n. 1
0
/**
 * Generates code to free all heap allocations on a tracker
 */
void _heap_freeusage(memuse_list_t *heap, int dofree)
{
  memuse_t *cur=heap->head;
  memuse_t *tmp;
  while (cur)
  {
    if (cur->type == MEMUSE_STATIC)
	{
      modheap((-1)*cur->size*sizeof(cell));
    } else {
      modheap_i();
    }
    if (dofree)
    {
      tmp=cur->prev;
      free(cur);
      cur=tmp;
    } else {
      cur=cur->prev;
    }
  }
  if (dofree)
  {
    heap->head=NULL;
  }
}
Esempio n. 2
0
// Generates code to free all heap allocations on a tracker
static void
modheap_for_scope(const MemoryScope& scope)
{
  for (size_t i = scope.usage.length() - 1; i < scope.usage.length(); i--) {
    const MemoryUse& use = scope.usage[i];
    if (use.type == MEMUSE_STATIC) {
      modheap((-1) * use.size * sizeof(cell));
    } else {
      modheap_i();
    }
  }
}