Subject | firebird api: who deallocs memory? |
---|---|
Author | C R Zamana |
Post date | 2002-02-21T15:57:54Z |
Hi fellows,
Below is an excerpt of my code. This function handles the
connection.
The question is: who must free the dpb variable?
I'm asking because when I try to free it my program
crashes, even if this free is called from the disconnection
function, after the disconnection.
I'm worry about this because my daemon is eating memory,
even if all that is done by the client is just connect and disconnect.
As long as I could check this is the only piece of memory that I'm
not freeing explicitly.
Thank you.
Best regards.
--------------------------------------------------------------------------
#include "rdd_api.h"
extern char *dpb;
ISC_LONG api_connect( char *db, char *user, char *pass, isc_db_handle
*dbhandle ) {
short dpb_length;
ISC_STATUS status_vector[20];
dpb = (char *)malloc(USERNAME_SIZE+PASSWORD_SIZE+2);
if ( dpb == NULL ) {
return(-1);
}
dpb_length = 0;
isc_expand_dpb( &dpb, &dpb_length, isc_dpb_user_name, user,
isc_dpb_password, pass, NULL );
isc_attach_database( status_vector, 0, db, dbhandle, dpb_length, dpb
);
if ( status_vector[0] == 1 && status_vector[1] ) {
isc_print_status(status_vector);
}
return( isc_sqlcode(status_vector) );
}
--------------------------------------------------------------------------
Below is an excerpt of my code. This function handles the
connection.
The question is: who must free the dpb variable?
I'm asking because when I try to free it my program
crashes, even if this free is called from the disconnection
function, after the disconnection.
I'm worry about this because my daemon is eating memory,
even if all that is done by the client is just connect and disconnect.
As long as I could check this is the only piece of memory that I'm
not freeing explicitly.
Thank you.
Best regards.
--------------------------------------------------------------------------
#include "rdd_api.h"
extern char *dpb;
ISC_LONG api_connect( char *db, char *user, char *pass, isc_db_handle
*dbhandle ) {
short dpb_length;
ISC_STATUS status_vector[20];
dpb = (char *)malloc(USERNAME_SIZE+PASSWORD_SIZE+2);
if ( dpb == NULL ) {
return(-1);
}
dpb_length = 0;
isc_expand_dpb( &dpb, &dpb_length, isc_dpb_user_name, user,
isc_dpb_password, pass, NULL );
isc_attach_database( status_vector, 0, db, dbhandle, dpb_length, dpb
);
if ( status_vector[0] == 1 && status_vector[1] ) {
isc_print_status(status_vector);
}
return( isc_sqlcode(status_vector) );
}
--------------------------------------------------------------------------