Subject | Re: UDF problem |
---|---|
Author | kittikira |
Post date | 2010-01-25T16:24:57Z |
First of all let me thank you so much for your help.
I modyfied the function as follows:
ISC_DATE * first_day (int * y, int * m)
{
ISC_DATE *bufdate = (ISC_DATE *) ib_util_malloc (sizeof(ISC_DATE));
struct tm tm1;
tm1.tm_sec = 0;
tm1.tm_min = 0;
tm1.tm_hour = 0;
tm1.tm_year = *y - IB_START_YEAR;
tm1.tm_mon = *m - 1;
tm1.tm_mday = 1;
isc_encode_sql_date(&tm1, bufdate);
return bufdate;
}
Still the same warning.
char * returnstr = (char * ) ib_util_malloc (31);
also gives this warning
char * returnstr = (char * ) malloc (31);
doesn't.
When using the UDF first_day in an SQL statement, firebird closes the connection.
I modyfied the function as follows:
ISC_DATE * first_day (int * y, int * m)
{
ISC_DATE *bufdate = (ISC_DATE *) ib_util_malloc (sizeof(ISC_DATE));
struct tm tm1;
tm1.tm_sec = 0;
tm1.tm_min = 0;
tm1.tm_hour = 0;
tm1.tm_year = *y - IB_START_YEAR;
tm1.tm_mon = *m - 1;
tm1.tm_mday = 1;
isc_encode_sql_date(&tm1, bufdate);
return bufdate;
}
Still the same warning.
char * returnstr = (char * ) ib_util_malloc (31);
also gives this warning
char * returnstr = (char * ) malloc (31);
doesn't.
When using the UDF first_day in an SQL statement, firebird closes the connection.
--- In firebird-support@yahoogroups.com, Dimitry Sibiryakov <sd@...> wrote:
>
> 25.01.2010 16:11, kittikira wrote:
> > Is there something wrong in this function?
>
> Yes. First of all, it is not compilable because of MALLOC. C is
> case-sensitive language. Second, you allocate too big buffer. Third, you
> use wrong type. ISC_QUAD is BLOB descriptor. For date you must use ISC_DATE.
>
> --
> SY, SD.
>