part of c programming
this example uses sph-sc-lib memreg
#include "sph/memreg.c" int main() { memreg_init(2); int* data_a = malloc(12 * sizeof(int)); if(!data_a) goto exit; // have to free nothing memreg_add(data_a); // more code ... char* data_b = malloc(20 * sizeof(char)); if(!data_b) goto exit; // have to free "data_a" memreg_add(data_b); // ... if (is_error) goto exit; // have to free "data_a" and "data_b" // ... exit: memreg_free; return(0); }