home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / os2 / rcs / rcs56src / source / gdbm / gdbm.bug / text0001.txt < prev   
Encoding:
Text File  |  1992-01-18  |  4.1 KB  |  143 lines

  1. These are the patches to gdbm-1.5 gdbmreorg.c I had to apply to fix the memory
  2. leaks and to stop the file descriptor walking as a function of the reorganise
  3. (this is a feature that was causing problems for an application sitting above
  4. gdbm - seemed like a good idea to include these patches).
  5. These patches include the previous patch I posted to stop incorrect assignment
  6. of the cache_entry pointer.
  7.  
  8. --- cut here
  9. *** gdbmreorg.c.old    Thu Jan  2 03:37:18 1992
  10. --- gdbmreorg.c    Sun Jan  5 13:00:47 1992
  11. ***************
  12. *** 74,79 ****
  13. --- 74,80 ----
  14.     gdbm_file_info *new_dbf;        /* The new file. */
  15.     char *new_name;            /* A temporary name. */
  16.     int  len;                /* Used in new_name construction. */
  17. +   int new_desc;                /* Used to avoid walking file desc */
  18.     datum key, nextkey, data;        /* For the sequential sweep. */
  19.     struct stat fileinfo;            /* Information about the file. */
  20.     int  index;                /* Use in moving the bucket cache. */
  21. ***************
  22. *** 131,138 ****
  23.             gdbm_close (new_dbf);
  24.             gdbm_errno = GDBM_REORGANIZE_FAILED;
  25.             unlink (new_name);
  26.             return -1;
  27. !         };
  28.        }
  29.         else
  30.        {
  31. --- 132,140 ----
  32.             gdbm_close (new_dbf);
  33.             gdbm_errno = GDBM_REORGANIZE_FAILED;
  34.             unlink (new_name);
  35. +           free(new_name);
  36.             return -1;
  37. !         }
  38.        }
  39.         else
  40.        {
  41. ***************
  42. *** 140,145 ****
  43. --- 142,148 ----
  44.         gdbm_close (new_dbf);
  45.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  46.         unlink (new_name);
  47. +       free(new_name);
  48.         return -1;
  49.        }
  50.         nextkey = gdbm_nextkey (dbf, key);
  51. ***************
  52. *** 153,164 ****
  53.       {
  54.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  55.         gdbm_close (new_dbf);
  56.         return -1;
  57.       }
  58.   
  59.     /* Fix up DBF to have the correct information for the new file. */
  60.     UNLOCK_FILE(dbf);
  61. !   close (dbf->desc);
  62.     free (dbf->header);
  63.     free (dbf->dir);
  64.     for (index = 0; index < CACHE_SIZE; index++)
  65. --- 156,178 ----
  66.       {
  67.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  68.         gdbm_close (new_dbf);
  69. +       unlink (new_name);
  70. +       free(new_name);
  71.         return -1;
  72.       }
  73.   
  74.     /* Fix up DBF to have the correct information for the new file. */
  75.     UNLOCK_FILE(dbf);
  76. !   /* close (dbf->desc); */
  77. !   if ((new_desc = dup2(new_dbf->desc, dbf->desc)) < 0)
  78. !     {
  79. !       gdbm_close(new_dbf);
  80. !       gdbm_errno = GDBM_REORGANIZE_FAILED;
  81. !       unlink (new_name);
  82. !       free(new_name);
  83. !       return -1;
  84. !     }
  85. !   dbf->desc = new_desc;
  86.     free (dbf->header);
  87.     free (dbf->dir);
  88.     for (index = 0; index < CACHE_SIZE; index++)
  89. ***************
  90. *** 169,180 ****
  91.       free (dbf->bucket_cache[index].ca_data.dptr);
  92.       }
  93.   
  94. !   dbf->desc           = new_dbf->desc;
  95.     dbf->header         = new_dbf->header;
  96.     dbf->dir            = new_dbf->dir;
  97.     dbf->bucket         = new_dbf->bucket;
  98.     dbf->bucket_dir     = new_dbf->bucket_dir;
  99. !   dbf->cache_entry    = new_dbf->cache_entry;
  100.     dbf->last_read      = new_dbf->last_read;
  101.     for (index = 0; index < CACHE_SIZE; index++)
  102.       dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
  103. --- 183,195 ----
  104.       free (dbf->bucket_cache[index].ca_data.dptr);
  105.       }
  106.   
  107. !   /* dbf->desc           = new_dbf->desc; */
  108.     dbf->header         = new_dbf->header;
  109.     dbf->dir            = new_dbf->dir;
  110.     dbf->bucket         = new_dbf->bucket;
  111.     dbf->bucket_dir     = new_dbf->bucket_dir;
  112. !   /* dbf->cache_entry    = new_dbf->cache_entry; */
  113. !   dbf->cache_entry    = &dbf->bucket_cache[new_dbf->last_read];
  114.     dbf->last_read      = new_dbf->last_read;
  115.     for (index = 0; index < CACHE_SIZE; index++)
  116.       dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
  117. ***************
  118. *** 187,192 ****
  119. --- 202,209 ----
  120.   
  121.     /* Make sure the new database is all on disk. */
  122.     fsync (dbf->desc);
  123. +   free(new_name);
  124.   
  125.     return 0;
  126.   }
  127. --- cut here
  128.  
  129. phil 
  130.  
  131.  ------------------------------------------------------------------------------
  132.    ___/   /
  133.    /_/)  /         Phil Male, Information Systems Engineering Group
  134.   / /_ '/  Computer Newspaper Services, The Bishops Manor, Howden, DN14 7BL
  135.  / / ///
  136.  ------------------------------------------------------------------------------
  137.  
  138. Confidence is the feeling you have before you understand the situation.
  139.  
  140.  
  141.  
  142.