All pastes #1831871 Raw Edit

Unnamed

public c v1 · immutable
#1831871 ·published 2010-03-10 14:17 UTC
rendered paste body
void ai_destroy_entity(struct entity *e){  ai_memory_counter -= (e->name ? strlen(e->name) + 1 : 0);  ai_memory_counter -= sizeof(e);  free(e->name);  free(e);}void ai_destroy_attribute(struct attriblist *a){  ai_memory_counter -= (a->name ? strlen(a->name) + 1 : 0);  ai_memory_counter -= (a->value ? strlen(a->value) + 1 : 0);  ai_memory_counter -= sizeof(a);  free(a->name);  free(a->value);  free(a);}void ai_destroy_fact(struct fact *f){  struct attriblist *a,*tmpa;  a = f->attribute->first;  while(a->next)  {    tmpa = a->next;    ai_destroy_attribute(a);    a = tmpa;  }  ai_destroy_attribute(a);  ai_destroy_entity(f->info);  ai_memory_counter -= sizeof(f);  free(f);}void ai_destroy_object(struct object *o){  struct fact *f,*tmpf;  struct attriblist *a,*tmpa;  ai_destroy_entity(o->info);  f = o->facts->first;  while(f->next)  {    tmpf = f->next;    ai_destroy_fact(f);    f = tmpf;  }  ai_destroy_fact(f);  a = o->attributes->first;  while(a->next)  {    tmpa = a->next;    ai_destroy_attribute(a);    a = tmpa;  }  ai_destroy_attribute(a);  ai_memory_counter -= sizeof(o);  free(o);}