Registering strings

When a PODS method returns a string, the caller should call the PODSMemoryMgr's stringFree() method to free the returned string.

When a PODS method returns a string, the implementer of the method may wish to register the string before returning it. Registering a string allows the developer to control what happens when the PODSMemoryMgr's stringFree() method is used to free the string. You may use stringFree() on an unregistered string, however, doing so will have no effect.

Most PODS authors will probably choose to use PODSMemoryMgr's stringDupAndRegister() method to duplicate and register strings. Calling stringFree() on a string made with stringDupAndRegister() will cause the string to be freed.

When you want finer control over the allocation of returned strings, you may use stringRegister(). Along with the string, stringRegister() takes a pointer to PODSFreeFunc and a void pointer as parameters. Later, when stringFree() is called, the PODSFreeFunc supplied for the string will be called and will be passed the string and the supplied void pointer. This void pointer may be used to store any necessary state. We expect stringDupAndRegister() to be sufficient for most PODS authors. But more complicated string management schemes, such as interning or reference counting, could be implemented using stringRegister().