Ignore:
Timestamp:
2011-05-19T12:10:52+12:00 (13 years ago)
Author:
jmt12
Message:

I'd misunderstood where I needed to free the memory allocated to storing char*s in the TDB_DATA. Apparently I only have to free them when they are returned by tdb_fetch() or similar. Removed segfault causing calls to free()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb-edit/trunk/src/src/tdbkeys-src/tdbkeys.cpp

    r24036 r24047  
    4747/**
    4848 */
    49 void 
    50 printUsage(char *program_name) 
     49void
     50printUsage(char *program_name)
    5151{
    5252  cerr << "usage: " << program_name << " <database_path>" << endl << endl;
     
    5959 *  @param argv - and char * array containing first the executable name, then
    6060 *                the name of/path to the database
    61  *  @return 0 
     61 *  @return 0
    6262 */
    6363int
     
    7676  int hash_size = 0;
    7777  int tdb_flags = TDB_DEFAULT;
    78   int open_flags = O_RDONLY; 
     78  int open_flags = O_RDONLY;
    7979  TDB_CONTEXT *tdb = tdb_open(dbname, hash_size, tdb_flags, open_flags, 0664);
    8080  if (!tdb)
     
    9797
    9898    /* free old key's dptr, otherwise causes memory leak */
    99     free(key.dptr); 
    100    
     99    free(key.dptr);
     100
    101101    /* can now safely copy content of nextkey into key */
    102102    key = nextkey;
    103103  }
    104  
     104
    105105  tdb_close(tdb);
    106106
Note: See TracChangeset for help on using the changeset viewer.