changeset 309:81ad865402e7

Fixed persistent index bug where indexName identifier was an un protected string pointer rather than a copy of the string. Hence the index name was getting deleted and the test for persistent index was failing.
author mas01mc
date Thu, 07 Aug 2008 17:05:22 +0000
parents 896679d8cc39
children 435ffdaecae9
files lshlib.cpp lshlib.h
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lshlib.cpp	Thu Aug 07 01:53:38 2008 +0000
+++ b/lshlib.cpp	Thu Aug 07 17:05:22 2008 +0000
@@ -418,13 +418,14 @@
 // Optionally load the LSH tables into head-allocated lists in core 
 G::G(char* filename, bool lshInCoreFlag):
   H(), // default base-class constructor call delays data-structure initialization 
-  indexName(filename),
+  indexName(0),
   lshHeader(0),
   calling_instance(0),
   add_point_callback(0)
 {
   int dbfid = unserialize_lsh_header(filename);
-
+  indexName = new char[O2_INDEX_MAXSTR];
+  strncpy(indexName, filename, O2_INDEX_MAXSTR); // COPY THE CONTENTS TO THE NEW POINTER
   H::initialize_lsh_functions(); // Base-class data-structure initialization
   unserialize_lsh_functions(dbfid); // populate with on-disk hashfunction values
 
--- a/lshlib.h	Thu Aug 07 01:53:38 2008 +0000
+++ b/lshlib.h	Thu Aug 07 17:05:22 2008 +0000
@@ -74,6 +74,8 @@
 #define O2_SERIAL_TOKEN_T2 (0xFFFFFFFDU)
 #define O2_SERIAL_TOKEN_ENDTABLE (0xFFFFFFFEU)
 
+#define O2_INDEX_MAXSTR (512)
+
 unsigned align_up(unsigned x, unsigned w);
 
 #define O2_SERIAL_FUNCTIONS_SIZE (align_up(sizeof(float) * O2_SERIAL_MAX_TABLES * O2_SERIAL_MAX_FUNS * O2_SERIAL_MAX_DIM \