M
Manish Tomar
Hi,
Assume I am developing a library that have couple of structs storing
some information:
struct A {
char *c;
struct B *b;
};
struct B {
char *str;
};
These structs are alloced on heap (I know I know.. C standard doesnt
define heap but I didnt know what else to write) using some lib API
and after using them the user frees it using their free functions
freeA() & freeB().
As a design decision I was wondering if the free functions should be
written like standard lib free function which does nothing when NULL
is passed or throw an error when NULL is passed. In other words,
should it expect NULL? If so, what should it do?
I am sorry if this seems like a real dumb question.
Thanks in advance,
Manish
Assume I am developing a library that have couple of structs storing
some information:
struct A {
char *c;
struct B *b;
};
struct B {
char *str;
};
These structs are alloced on heap (I know I know.. C standard doesnt
define heap but I didnt know what else to write) using some lib API
and after using them the user frees it using their free functions
freeA() & freeB().
As a design decision I was wondering if the free functions should be
written like standard lib free function which does nothing when NULL
is passed or throw an error when NULL is passed. In other words,
should it expect NULL? If so, what should it do?
I am sorry if this seems like a real dumb question.
Thanks in advance,
Manish