Memory Ownership in C API Functions - Aster Execution Engine

Teradata Aster® Developer Guide

Product
Aster Execution Engine
Release Number
7.00.02
Published
July 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
xnl1494366523182.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
ffu1489104705746
lifecycle
previous
Product Category
Software

Managing memory correctly is an important part of programming against the user defined function API in C and C++. One central concept of memory management is ownership. In general, if your code owns some memory, that memory is your responsibility, and you must release it appropriately (sometimes with the sqlmr_release function and sometimes with a type-specific sqlmr_*_releaseOwned function, as described in the API reference documentation). For memory that your code does not own, the user defined function framework will release the memory, so your code must not release it or modify it.

Functions in the user defined function API never take ownership of data given to them, but they may transfer ownership to the caller. The reference documentation for the user defined function API describes the rules for memory ownership in detail on a function-by-function basis.

Memory must be released with the appropriate function. Do not use the C library free function or the C++ delete operator to release objects that have been provided by the user defined function framework. (Of course, if you have allocated some memory yourself, then you must free that memory as usual when it is no longer needed.)