From c7e942a8ff90fe6100518361129209a7cd5ab48d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2004 10:46:23 +0000 Subject: added ndb_mgm_destroy_configuration call fixed memory leak in object map fixed uninitialized value blobs_pending ndb/include/mgmapi/mgmapi.h: added ndb_mgm_destroy_configuration call ndb/src/mgmapi/mgmapi.cpp: added ndb_mgm_destroy_configuration call ndb/src/ndbapi/ObjectMap.hpp: fixed memory leak ndb/src/ndbapi/ndb_cluster_connection.cpp: added ndb_mgm_destroy_configuration call sql/ha_ndbcluster.cc: fixed uninitialized value blobs_pending --- ndb/include/mgmapi/mgmapi.h | 3 ++- ndb/src/mgmapi/mgmapi.cpp | 8 ++++++++ ndb/src/ndbapi/ObjectMap.hpp | 5 ++++- ndb/src/ndbapi/ndb_cluster_connection.cpp | 2 +- sql/ha_ndbcluster.cc | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index 123297b0d71..a745688561c 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -664,10 +664,11 @@ extern "C" { * @param handle NDB management handle. * @param version Version of configuration, 0 means latest * @see MAKE_VERSION - * @Note the caller must free the pointer returned. + * @Note the caller must call ndb_mgm_detroy_configuration */ struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle, unsigned version); + void ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *); int ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned version, diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index e78b0d41cf2..0f65d9425ae 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -1508,6 +1508,14 @@ ndb_mgm_get_configuration(NdbMgmHandle handle, unsigned int version) { return 0; } +extern "C" +void +ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *cfg) +{ + if (cfg) + delete (ConfigValues *)cfg; +} + extern "C" int ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, unsigned *pnodeid, int nodetype) diff --git a/ndb/src/ndbapi/ObjectMap.hpp b/ndb/src/ndbapi/ObjectMap.hpp index f67774bb413..6c984c644e2 100644 --- a/ndb/src/ndbapi/ObjectMap.hpp +++ b/ndb/src/ndbapi/ObjectMap.hpp @@ -134,7 +134,10 @@ NdbObjectIdMap::expand(Uint32 incSize){ Uint32 newSize = m_size + incSize; MapEntry * tmp = (MapEntry*)malloc(newSize * sizeof(MapEntry)); - memcpy(tmp, m_map, m_size * sizeof(MapEntry)); + if (m_map) { + memcpy(tmp, m_map, m_size * sizeof(MapEntry)); + free((void*)m_map); + } m_map = tmp; for(Uint32 i = m_size; istart_instance(nodeId, props); - free(props); + ndb_mgm_destroy_configuration(props); m_facade->connected(); DBUG_RETURN(0); } while(0); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 050a7fae607..6ce769620e4 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3196,6 +3196,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): bulk_insert_rows(1024), bulk_insert_not_flushed(false), ops_pending(0), + blobs_pending(0), skip_auto_increment(true), blobs_buffer(0), blobs_buffer_size(0), -- cgit v1.2.1