#include enum aplwc_rc aplwc_new(struct aplwc **p, uint8_t *data, size_t size) { struct memory m; m = memory_init(data, size); *p = memory_alloc_aplwc(&m); if(*p == NULL) return APLWC_OUT_OF_MEMORY; (*p)->memory = m; return APLWC_OK; } enum aplwc_rc aplwc_destroy(struct aplwc *p) { if(p) memory_free_aplwc(&p->memory, p); return APLWC_OK; } const char * aplwc_errstr_rc(enum aplwc_rc rc) { switch(rc){ case APLWC_OK: return ""; case APLWC_OUT_OF_MEMORY: return "Out of memory"; default: return "(unable to produce error string)"; } } const char * aplwc_errstr(struct aplwc *aplwc) { enum { BUF_SIZE = 256 }; const char *err; enum aplwc_rc rc; err = NULL; rc = aplwc ? aplwc->last_error : APLWC_RC_LAST+1; err = aplwc_errstr_rc(rc); return err; }