I'm not sure why `dot` is declared, since you should be able to simply pass `"."` to `strsep()`. In any event, `dot` is never dynamically allocated so there's no reason you would need to free it.

If I grok [strsep(3)](http://linux.die.net/man/3/strsep) correctly, it's going to find the first occurrence of `"."` (or whatever the separator string is) and replace the first character position with a null byte. `strsep()` then skips past the separator and modifies *its* first argument to point to the bit of the string following the separator's occurrence. I *think* in this case you would need to just free `db_name`, since it is the only pointer with the same memory address as the originally allocated memory.

Frankly, I think it'd be much easier to just use `strchr()` to find the first `'.'` character in `db_and_collection` and then allocate `db_name` and `collection_name` and `strncpy()` appropriately. Then you can free both at the end of the function.