[net.unix-wizards] mdbm deletion bug

dave@uwvax.UUCP (08/13/84)

I tried out the mdbm software from Maryland and found a problem when
deleting records.  The problem is that mdbm keeps track of the number
of keys in its buffer table (I think) and the deletion stuff doesn't
take this into account when deleting records.  The fix is in delete.c
and a diff follows.  Basically, delete must re-retrieve the key to get
its updated index before deleting it.  With this fix, the mdbm software
seems to work very well.

*** delete.c.orig	Mon Aug 13 03:30:17 1984
--- delete.c	Mon Aug 13 03:28:13 1984
***************
*** 34,39
  	mdbm_delitem (d, de - db -> db_e);
  
  	/* delete the key */
  	MDBM_DREAD (d, keyblock);
  	de = &db -> db_e[keyindex];
  	de -> de_outx = 0;		/* not in use as a key anymore */

--- 34,40 -----
  	mdbm_delitem (d, de - db -> db_e);
  
  	/* delete the key */
+ 	de = mdbm_search (d, key.dptr, key.dsize, &keyblock, &keyindex, 1);
  	MDBM_DREAD (d, keyblock);
  	de = &db -> db_e[keyindex];
  	de -> de_outx = 0;		/* not in use as a key anymore */

-- 
Dave Cohrs @ wisconsin
...!{allegra,heurikon,ihnp4,seismo,ucbvax,uwm-evax}!uwvax!dave
dave@wisc-rsch.arpa