> v.s. explicit headache of alloc/free, which doesn't fix > use-after-free anyway and just adds more boiler plate > plus makes code har to read read > > str = aml_alloc(); > aml_string(str, "foo"); > loc0 = aml_alloc(); > aml_local(loc0, 0); > store = aml_alloc(); > aml_store(store, str, loc0); > aml_append(method, store); > aml_free(store); > aml_free(loc0); > aml_free(str);
Looks like I wasn't clear. This is what I propose: void aml_add_method(AmlPool *pool, AmlBlob *aml) { AmlBlob *str = aml_alloc(pool); aml_string(str, "foo"); loc0 = aml_alloc(pool); aml_local(loc0, 0); AmlBob *store = aml_alloc(pool); aml_store(store, str, loc0); aml_append(method, store); } So just propagare AmlPool* everywhere, don't free. Then at top level: AmlPool *pool = aml_pool_alloc(); AmlSsdt = aml_add_ssdt(pool, ....); .... aml_pool_free(pool); So from API perspective, this is very close to what you posted, with just two changes: - pass pool parameter everywhere - have an extra alloc/free in only one place. Happy? -- MST