3 ms·
Namespacing was mentioned by another comment, but I do something like this: libname_module_function(); So for my bc [1], I do this: bc_parse_if(...);
by gavinhoward 3y ago
Namespacing was mentioned by another comment, but I do something like this:
libname_module_function();
So for my bc [1], I do this:
bc_parse_if(...);
That parses an `if` statement.
For destructors, I want them to be passed and stored as first-class entities, so I defined them like this:
typedef void (*BcDestructor)(void* item);
Then things like my resizable arrays store the destructor for the items in the array, and when items are removed (popped, whatever), the destructor is run on the item if the destructor is not NULL.
Works like a charm.
Edit: There is one danger to the destructors: you can pass the wrong type of pointer. But if this happens, you'll probably get a lot of Valgrind errors and a spectacular crash.