If there is the 'struct foo' and an APIs which handle foo, which is more flexible and convenient API?
1) API only initialize foo. User should declare foo or allocate memory for foo. The this style is like pthread_mutex_init/pthread_mutex_destroy.
example 1)
struct foo a;
init_foo(&a);'
example 2)
struct foo *a;
a = malloc(sizeof(struct foo));
init_foo(a);
2) API allocates memory and user get the pointer. This is like getaddrinfo/freeaddrinfo.
example)
struct foo *a;
get_foo(&a);
put_foo(a);