@ -186,16 +186,23 @@ all of the characters, and replace any invalid characters with an underscore.
### Construction/Destruction Functions
### Construction/Destruction Functions
For functions that are responsible for constructing and destructing an object,
Functions that are responsible for constructing objects should take one of the
they should be written as a pair of one of two forms:
two following forms:
* `init` /`finish`: These initialize/deinitialize a type, but are **NOT**
responsible for allocating it. They should accept a pointer to some
* `init` : for functions which accept a pointer to a pre-allocated object (e.g.
pre-allocated memory (e.g. a member of a struct).
a member of a struct) and initialize it.
* `create` /`destroy`: These also initialize/deinitialize, but will return a
* `create` : for functions which allocate the memory for an object, initialize
pointer to a `malloc` ed chunk of memory, and will `free` it in `destroy` .
it, and return a pointer.
A destruction function should always be able to accept a NULL pointer or a
Likewise, functions that are responsible for destructing objects should take
zeroed value and exit cleanly; this simplifies error handling a lot.
one of the two following forms:
* `finish` : for functions which accept a pointer to an object and deinitialize
it. Such functions should always be able to accept an already deinitialized
object.
* `destroy` : for functions which accept a pointer to an object, deinitialize
it, and free the memory. Such functions should always be able to accept a NULL
pointer.
### Error Codes
### Error Codes