Currently, the text index data-structures hold on to references of the input data (const char *) that they are passed. Once the original data is destroyed, the data-structures begin to mal-function since the reference it's holding on to points to data that may no longer exist.
A simple solution is to copy the entire input data to a newly allocated buffer within each of the data-structures. The responsibility of freeing the original input buffer would lie with the caller, and the responsibility of freeing the new copy would lie with the text-index data-structure.
Currently, the text index data-structures hold on to references of the input data (
const char *) that they are passed. Once the original data is destroyed, the data-structures begin to mal-function since the reference it's holding on to points to data that may no longer exist.A simple solution is to copy the entire input data to a newly allocated buffer within each of the data-structures. The responsibility of freeing the original input buffer would lie with the caller, and the responsibility of freeing the new copy would lie with the text-index data-structure.