diff options
Diffstat (limited to 'src/gdbmstore.c')
-rw-r--r-- | src/gdbmstore.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gdbmstore.c b/src/gdbmstore.c index 3ba882e..f166ba9 100644 --- a/src/gdbmstore.c +++ b/src/gdbmstore.c @@ -47,26 +47,26 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags) int new_size; /* Used in allocating space. */ int rc; /* First check to make sure this guy is a writer. */ if (dbf->read_write == GDBM_READER) { - gdbm_errno = GDBM_READER_CANT_STORE; + gdbm_set_errno (dbf, GDBM_READER_CANT_STORE, 0); return -1; } /* Check for illegal data values. A NULL dptr field is illegal because NULL dptr returned by a lookup procedure indicates an error. */ if ((key.dptr == NULL) || (content.dptr == NULL)) { - gdbm_errno = GDBM_ILLEGAL_DATA; + gdbm_set_errno (dbf, GDBM_ILLEGAL_DATA, 0); return -1; } /* Initialize the gdbm_errno variable. */ - gdbm_errno = GDBM_NO_ERROR; + gdbm_set_errno (dbf, GDBM_NO_ERROR, 0); /* Look for the key in the file. A side effect loads the correct bucket and calculates the hash value. */ elem_loc = _gdbm_findkey (dbf, key, NULL, &new_hash_val); /* Initialize these. */ @@ -91,17 +91,19 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags) /* Just reuse the same address! */ file_adr = free_adr; } } else { - gdbm_errno = GDBM_CANNOT_REPLACE; + gdbm_set_errno (dbf, GDBM_CANNOT_REPLACE, 0); return 1; } } - else if (gdbm_errno != GDBM_ITEM_NOT_FOUND) + else if (gdbm_errno == GDBM_ITEM_NOT_FOUND) + gdbm_set_errno (dbf, GDBM_NO_ERROR, 0); //clear error state + else return -1; /* Get the file address for the new space. (Current bucket's free space is first place to look.) */ if (file_adr == 0) file_adr = _gdbm_alloc (dbf, new_size); |