lex *lex_create(const char *input) { lex *c; c = calloc(1, sizeof(*c)); if (c == NULL) return NULL; c->peek = ' '; c->sym = sym_create(); if (c->sym == NULL) goto oom; c->lexbuf = malloc(256); if (c->lexbuf == NULL) goto oom; c->lexbufsz = 256; c->input = input; return c; oom: sym_destroy(c->sym); free(c->lexbuf); free(c); return NULL; }
void lex_destroy(lex *doomed) { if (doomed == NULL) return; sym_destroy(doomed->sym); free(doomed->lexbuf); free(doomed); }
void zebra_image_scanner_destroy (zebra_image_scanner_t *iscn) { if(iscn->scn) zebra_scanner_destroy(iscn->scn); iscn->scn = NULL; if(iscn->dcode) zebra_decoder_destroy(iscn->dcode); iscn->dcode = NULL; while(iscn->syms) { zebra_symbol_t *next = iscn->syms->next; sym_destroy(iscn->syms); iscn->syms = next; } free(iscn); }