…c-template * template/c-template: Use all LDFLAGS when linking via pkgconfig Fix macros for cmake 2.8.7 Enable static libraries Add cmake helper macros
We provide a "debug" allocator, which verifies that the sizes that you provide to the allocation functions matches the sizes that you provide to the deallocation functions. Before, we used the builtin `assert` macro to perform this check. However, that means that if we compile libcork in `Release` mode (in which asserts are left out), we never actually perform the check! We now use an explicit check, and call `abort` ourselves if the check fails — our assumption being that if you ask for the debug allocator, you want at least this particular bit of debug behavior even if the rest of the library was compiled in `Release` mode.
We need to be careful about when we're passing the `__SOURCES` variable as a list (and therefore don't want to quote it). We can't use `target_include_directories` before 2.8.12, and need to fall back on `include_directories` if it isn't available. And we have to explicitly include the file that defines `cmake_parse_arguments` on some earlier cmake versions (although I'm not sure precisely where the boundary is).
* template/c-template: Separate out major/minor/patch versions
Our template already grabs the current version from git tags. We now also separate this out in major, minor, and patch versions, stored in the `VERSION_MAJOR`, `VERSION_MINOR`, and `VERSION_PATCH` cmake variables, respectively. We also grab the SHA-1 identifier of the current git commit and store that in the `GIT_SHA1` variable. (Note that this means that the cmake scripts only work from a valid git checkout. The version detection tries to support working from a release tarball, as well, but we don't currently have a good mechanism for generating one of those. Once we do, we should tweak all of this to work there, too.)
The `cork_strndup` and `cork_xstrndup` functions were using `strncpy` under the covers to make the copy of the incoming string. This truncates the copy at the first NUL byte. We want to copy the whole thing, so we should use `memcpy` instead.
Before we were using a `cork_mempool` to allocate all of the entries that are stored in a hash table. This reduces the number of times that we have to call `malloc`, but currently the mempool implementation isn't able to return memory to the OS. That makes it less than ideal for a hash table that grows and shrinks during its existence. Plus, now that we have customizable allocation, a better approach is for your application to use a better `malloc` implementation, like jemalloc or tcmalloc.