UDF Memory Allocation

Any memory allocated to a UDF is taken back by the system after the UDF exits. Input arguments remain allocated for the lifetime of a function. You can refer to the input arguments in expressions for return values. When using temporary variables to construct all new string values, use the StringValue() constructor, and copy the data into the newly allocated memory buffer. The StringValue() constructor takes an initial FunctionContext* argument followed by a length.