Hi!
Just noticed that I had missed this email. Better to get an answer
late than never...
>>>>> "Alaric" == Alaric Snell-Pym <alaric@stripped> writes:
Alaric> On 14 May 2009, at 12:39 am, Michael Widenius wrote:
Alaric> That, combined with the fact that in my recent foray into
>> UDFs I found
Alaric> that string UDFs are passed a buffer with room for 255
>> characters to
Alaric> put their result into, and then have the choice of using it
>> and
Alaric> returning a pointer to it or mallocing their own buffer and
>> returning
Alaric> a pointer to that (meaning that the caller, somewhere, must
>> have code
Alaric> to the effect of "if (returned_ptr != allocated_buffer)
Alaric> free(returned_ptr)" to clear up, I guess?),
>>
>> Actually the idea was that you would in your object remember the
>> malloc you did and then free it.
>>
>> So the code would be in the destructor:
>>
>> x_free(malloc_pointer);
Alaric> What object? In a UDF, I just declare a function, as per
> http://dev.mysql.com/doc/refman/5.1/en/udf-return-values.html
Alaric> - I surrender the pointer to mysql when I return, and have no chance
Alaric> to free it myself?
<cut>
You should store a copy of the pointer you alloc and free it in the
destructor.
See 'sequence_init()' in udf_example.c
Regards,
Monty