Allocation of Input Values
 
 
 

As a rule, the API developer is not responsible for allocation of arguments to functions.

For example, if a function takes a string as an argument, that string will be duplicated by the API. The developer may then deallocate the string. The exceptions to this rule are the old blind data interface (user defined and only accessible through the API) and comments. Blind data is not copied on input. Rather, a pointer to the user’s buffer is kept in the Alias object. As long as a reference exists from Alias to that blind data, the developer should avoid deleting the associated buffer. Note that when the wire file is stored, the blind data is copied into the wire file. When a wire file is retrieved, any blind data will then be copied into a newly allocated buffer. This has the same effect as creating duplicates of any shared blind data. As a general rule it is not a good idea to allow objects to share blind data.

Blind Data and New and Delete

Using the C++ new and delete functions to create and destroy memory for blind data can lead to program errors. There are several cases where Alias or OpenModel will need to remove or re-create blind data during normal operations. If a delete all operation is performed, all blind data is removed. If blind data is saved in the wire file, when the file is read in the blind data storage will be recreated. OpenAlias and OpenModel will use malloc() and free() for its blind data memory creation and destruction routines. Problems may occur if the blind data has been created with the new command since the wrong creation and destruction routine for the memory block would be used. As a general rule malloc() should be used to allocate memory used for blind data or comments.

NoteThere are currently two ways of managing blind data within the API. You can use the old blind data methods(setBlindData(), blindData(), removeBlindData()) or use the new AlBlindData class. The rules above apply to the old blind data methods rather than the AlBlindData class.