home *** CD-ROM | disk | FTP | other *** search
- These are the patches to gdbm-1.5 gdbmreorg.c I had to apply to fix the memory
- leaks and to stop the file descriptor walking as a function of the reorganise
- (this is a feature that was causing problems for an application sitting above
- gdbm - seemed like a good idea to include these patches).
- These patches include the previous patch I posted to stop incorrect assignment
- of the cache_entry pointer.
-
- --- cut here
- *** gdbmreorg.c.old Thu Jan 2 03:37:18 1992
- --- gdbmreorg.c Sun Jan 5 13:00:47 1992
- ***************
- *** 74,79 ****
- --- 74,80 ----
- gdbm_file_info *new_dbf; /* The new file. */
- char *new_name; /* A temporary name. */
- int len; /* Used in new_name construction. */
- + int new_desc; /* Used to avoid walking file desc */
- datum key, nextkey, data; /* For the sequential sweep. */
- struct stat fileinfo; /* Information about the file. */
- int index; /* Use in moving the bucket cache. */
- ***************
- *** 131,138 ****
- gdbm_close (new_dbf);
- gdbm_errno = GDBM_REORGANIZE_FAILED;
- unlink (new_name);
- return -1;
- ! };
- }
- else
- {
- --- 132,140 ----
- gdbm_close (new_dbf);
- gdbm_errno = GDBM_REORGANIZE_FAILED;
- unlink (new_name);
- + free(new_name);
- return -1;
- ! }
- }
- else
- {
- ***************
- *** 140,145 ****
- --- 142,148 ----
- gdbm_close (new_dbf);
- gdbm_errno = GDBM_REORGANIZE_FAILED;
- unlink (new_name);
- + free(new_name);
- return -1;
- }
- nextkey = gdbm_nextkey (dbf, key);
- ***************
- *** 153,164 ****
- {
- gdbm_errno = GDBM_REORGANIZE_FAILED;
- gdbm_close (new_dbf);
- return -1;
- }
-
- /* Fix up DBF to have the correct information for the new file. */
- UNLOCK_FILE(dbf);
- ! close (dbf->desc);
- free (dbf->header);
- free (dbf->dir);
- for (index = 0; index < CACHE_SIZE; index++)
- --- 156,178 ----
- {
- gdbm_errno = GDBM_REORGANIZE_FAILED;
- gdbm_close (new_dbf);
- + unlink (new_name);
- + free(new_name);
- return -1;
- }
-
- /* Fix up DBF to have the correct information for the new file. */
- UNLOCK_FILE(dbf);
- ! /* close (dbf->desc); */
- ! if ((new_desc = dup2(new_dbf->desc, dbf->desc)) < 0)
- ! {
- ! gdbm_close(new_dbf);
- ! gdbm_errno = GDBM_REORGANIZE_FAILED;
- ! unlink (new_name);
- ! free(new_name);
- ! return -1;
- ! }
- ! dbf->desc = new_desc;
- free (dbf->header);
- free (dbf->dir);
- for (index = 0; index < CACHE_SIZE; index++)
- ***************
- *** 169,180 ****
- free (dbf->bucket_cache[index].ca_data.dptr);
- }
-
- ! dbf->desc = new_dbf->desc;
- dbf->header = new_dbf->header;
- dbf->dir = new_dbf->dir;
- dbf->bucket = new_dbf->bucket;
- dbf->bucket_dir = new_dbf->bucket_dir;
- ! dbf->cache_entry = new_dbf->cache_entry;
- dbf->last_read = new_dbf->last_read;
- for (index = 0; index < CACHE_SIZE; index++)
- dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
- --- 183,195 ----
- free (dbf->bucket_cache[index].ca_data.dptr);
- }
-
- ! /* dbf->desc = new_dbf->desc; */
- dbf->header = new_dbf->header;
- dbf->dir = new_dbf->dir;
- dbf->bucket = new_dbf->bucket;
- dbf->bucket_dir = new_dbf->bucket_dir;
- ! /* dbf->cache_entry = new_dbf->cache_entry; */
- ! dbf->cache_entry = &dbf->bucket_cache[new_dbf->last_read];
- dbf->last_read = new_dbf->last_read;
- for (index = 0; index < CACHE_SIZE; index++)
- dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
- ***************
- *** 187,192 ****
- --- 202,209 ----
-
- /* Make sure the new database is all on disk. */
- fsync (dbf->desc);
- +
- + free(new_name);
-
- return 0;
- }
- --- cut here
-
- phil
-
- ------------------------------------------------------------------------------
- ___/ /
- /_/) / Phil Male, Information Systems Engineering Group
- / /_ '/ Computer Newspaper Services, The Bishops Manor, Howden, DN14 7BL
- / / ///
- ------------------------------------------------------------------------------
-
- Confidence is the feeling you have before you understand the situation.
-
-
-
-