MYDDAS: Fix a bug on memory dealocation on MYDDAS_STATS module
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1669 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -1,42 +1,60 @@
|
||||
//* Initializes a new connection node for the MYDDAS list*/
|
||||
static MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_initialize_connection(void *,void *,
|
||||
MYDDAS_UTIL_CONNECTION);
|
||||
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL
|
||||
|
||||
/* Initializes a new predicate node for the MYDDAS list */
|
||||
static MYDDAS_UTIL_PREDICATE
|
||||
myddas_util_initialize_predicate(char *, int,char *,
|
||||
MYDDAS_UTIL_PREDICATE);
|
||||
#include "Yap.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "myddas.h"
|
||||
#include "myddas_structs.h"
|
||||
#ifdef MYDDAS_STATS
|
||||
#include "myddas_statistics.h"
|
||||
#endif
|
||||
|
||||
MYDDAS_GLOBAL
|
||||
myddas_util_initialize_myddas(void){
|
||||
myddas_init_initialize_myddas(void){
|
||||
MYDDAS_GLOBAL global = NULL;
|
||||
|
||||
/* We cannot call MYDDAS_MALLOC were because the global
|
||||
register isn't yet initialized */
|
||||
global = (MYDDAS_GLOBAL) malloc (sizeof(struct myddas_global));
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("MALLOC %p %s %d\n",global,__FILE__,__LINE__);
|
||||
#endif
|
||||
global->myddas_top_connections = NULL;
|
||||
#ifdef MYDDAS_TOP_LEVEL
|
||||
global->myddas_top_level_connection = NULL;
|
||||
#endif
|
||||
#ifdef MYDDAS_STATS
|
||||
global->myddas_statistics = (MYDDAS_GLOBAL_STATS) malloc (sizeof(struct myddas_global_stats));
|
||||
#ifdef DEBUG
|
||||
printf ("MALLOC %p %s %d\n",global->myddas_statistics,__FILE__,__LINE__);
|
||||
#endif
|
||||
global->myddas_statistics->stats = NULL;
|
||||
MYDDAS_STATS_INITIALIZE_GLOBAL_STATS(global->myddas_statistics->stats);
|
||||
//MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_db_row,time_final);
|
||||
//MYDDAS_STATS_INITIALIZE_TIME_STRUCT(global->myddas_statistics->total_translate,time_final);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
/* We first malloc for this struct and the stats struct */
|
||||
#ifdef MYDDAS_STATS
|
||||
global->malloc_called = 2;
|
||||
global->memory_allocated = sizeof(struct myddas_global) + sizeof(struct myddas_global_stats);
|
||||
#else
|
||||
global->malloc_called = 1;
|
||||
global->memory_allocated = sizeof(struct myddas_global);
|
||||
#endif /* MYDDAS_STATS */
|
||||
global->free_called = 0;
|
||||
global->memory_freed = 0;
|
||||
#endif
|
||||
|
||||
return global;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Inserts the new node on the front of the list */
|
||||
static MYDDAS_UTIL_CONNECTION
|
||||
myddas_util_initialize_connection(void *conn,void *enviromment,
|
||||
MYDDAS_UTIL_CONNECTION
|
||||
myddas_init_initialize_connection(void *conn,void *enviromment,
|
||||
MYDDAS_UTIL_CONNECTION next){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION new = malloc (sizeof(struct myddas_list_connection));
|
||||
MYDDAS_UTIL_CONNECTION new = NULL;
|
||||
MYDDAS_MALLOC(new,struct myddas_list_connection);
|
||||
|
||||
if (new == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@@ -60,16 +78,18 @@ myddas_util_initialize_connection(void *conn,void *enviromment,
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
new->stats = NULL;
|
||||
MYDDAS_STATS_INITIALIZE_CONNECTION_STATS(new->stats);
|
||||
new->stats = myddas_stats_initialize_connection_stats();
|
||||
#endif
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
static MYDDAS_UTIL_PREDICATE
|
||||
myddas_util_initialize_predicate(char *pred_name, int pred_arity,
|
||||
MYDDAS_UTIL_PREDICATE
|
||||
myddas_init_initialize_predicate(char *pred_name, int pred_arity,
|
||||
char *pred_module, MYDDAS_UTIL_PREDICATE next){
|
||||
MYDDAS_UTIL_PREDICATE new = malloc (sizeof(struct myddas_list_preds));
|
||||
|
||||
MYDDAS_UTIL_PREDICATE new = NULL;
|
||||
MYDDAS_MALLOC(new,struct myddas_list_preds);
|
||||
|
||||
if (new == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@@ -89,3 +109,4 @@ myddas_util_initialize_predicate(char *pred_name, int pred_arity,
|
||||
return new;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user