Subject | UDF memory allocation for result string in Linux |
---|---|
Author | ma_golyo |
Post date | 2012-04-17T07:01:46Z |
Hi!
When I run my UDF (udf_op), I get an error : "Bad written UDF detected: pointer returned in FREE_IT function was not allocated by ib_util_malloc"
I use ib_util_malloc in my Win version, no problem there. What should I use in Linux version? Currently memory allocated with malloc.
SQL:
DECLARE EXTERNAL FUNCTION UDF_OP
RETURNS CSTRING(10) FREE_IT
ENTRY_POINT 'udf_op' MODULE_NAME 'UDF3s';
C:
char * udf_op();
char * udf_op()
{
char *buffer = (char *)malloc(10);
strncpy(buffer, "Linux", 6);
return buffer;
}
C compiled with :
gcc -c -O -fpic UDF3s.c
ld -G UDF3s.o -lm -lc -o UDF3s.so
Thank You!
When I run my UDF (udf_op), I get an error : "Bad written UDF detected: pointer returned in FREE_IT function was not allocated by ib_util_malloc"
I use ib_util_malloc in my Win version, no problem there. What should I use in Linux version? Currently memory allocated with malloc.
SQL:
DECLARE EXTERNAL FUNCTION UDF_OP
RETURNS CSTRING(10) FREE_IT
ENTRY_POINT 'udf_op' MODULE_NAME 'UDF3s';
C:
char * udf_op();
char * udf_op()
{
char *buffer = (char *)malloc(10);
strncpy(buffer, "Linux", 6);
return buffer;
}
C compiled with :
gcc -c -O -fpic UDF3s.c
ld -G UDF3s.o -lm -lc -o UDF3s.so
Thank You!