void dd_destroyImage(ddImage* image) { if ( image->flags & DDIMAGE_ALLOCEDBUFFER ) dd_free(image->data); dd_free(image); }
void dd_destroyCharacterList(ddCharacterList* list) { int i; if ( list->chars != NULL ) { for ( i = 0; i < list->nChars; ++i ) { if ( list->chars[i] != NULL ) dd_destroyCharacter(list->chars[i]); } dd_free(list->chars); } dd_free(list); }
static void dd_destroyText(ddCharacter* c) { ddText* text = (ddText*)c; struct _ddTextRecord *record = text->record; struct _ddTextRecord *next; while ( record != NULL ) { next = record->next; dd_free(record->glyphs); dd_free(record->advances); dd_free(record); record = next; } dd_free(text); }
static void dd_destroyFont(ddCharacter* c) { ddFont* font = (ddFont*)c; int i; for ( i = 0; i < font->nGlyphs; ++i ) { if ( font->glyphs[i] != NULL ) dd_destroyShape(font->glyphs[i]); } dd_free(font->glyphs); dd_free(font->advances); dd_free(font->charmap); if ( font->name != NULL ) dd_free(font->name); dd_free(c); }
int main(){ struct dlist *l = dd_new(); if (l == NULL){ printf("malloc err\n"); return -1; } dd_insert(l, "Gislene", 1); dd_insert(l, "Antonio", 3); dd_insert(l, "Emma", 5); dd_insertn(l, "Filip", 2, -2); print(l); putchar('\n'); printn(l); dd_free(l); return 0; }