summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org>2018-06-23 10:38:05 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-06-23 10:38:05 (GMT)
commitc458171c6deaa9a8eb70d2f9c2c21a129daeb32d (patch) (side-by-side diff)
tree56f55c7d84851327c5cd9a244a9e58662264feb6 /src
parent551d394440d820e877e73c048f8ea4ba1d27bf17 (diff)
downloadgdbm-c458171c6deaa9a8eb70d2f9c2c21a129daeb32d.tar.gz
gdbm-c458171c6deaa9a8eb70d2f9c2c21a129daeb32d.tar.bz2
Bugfixes. Consistently use the coalesce_blocks flag.
* src/bucket.c (_gdbm_split_bucket): Take into account coalesce_blocks * src/falloc.c (_gdbm_put_av_elem): Change to void return. All uses changed. * src/proto.h: Likewise.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/bucket.c9
-rw-r--r--src/falloc.c21
-rw-r--r--src/proto.h2
3 files changed, 15 insertions, 17 deletions
diff --git a/src/bucket.c b/src/bucket.c
index 4b69bbe..0597965 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -361,7 +361,8 @@ _gdbm_split_bucket (GDBM_FILE dbf, int next_insert)
/* The avail is full, move the first one to bucket[1]. */
_gdbm_put_av_elem (dbf->bucket->bucket_avail[0],
bucket[1]->bucket_avail,
- &bucket[1]->av_count, FALSE);
+ &bucket[1]->av_count,
+ dbf->coalesce_blocks);
index = 1;
bucket[0]->av_count--;
}
@@ -404,7 +405,8 @@ _gdbm_split_bucket (GDBM_FILE dbf, int next_insert)
dbf->cache_entry = &dbf->bucket_cache[cache_0];
_gdbm_put_av_elem (old_bucket,
bucket[1]->bucket_avail,
- &bucket[1]->av_count, FALSE);
+ &bucket[1]->av_count,
+ dbf->coalesce_blocks);
}
else
{
@@ -412,7 +414,8 @@ _gdbm_split_bucket (GDBM_FILE dbf, int next_insert)
dbf->cache_entry = &dbf->bucket_cache[cache_1];
_gdbm_put_av_elem (old_bucket,
bucket[0]->bucket_avail,
- &bucket[0]->av_count, FALSE);
+ &bucket[0]->av_count,
+ dbf->coalesce_blocks);
}
}
diff --git a/src/falloc.c b/src/falloc.c
index 2fb8ea1..a2b3fd9 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -92,8 +92,6 @@ _gdbm_alloc (GDBM_FILE dbf, int num_bytes)
}
-
-
/* Free space of size NUM_BYTES in the file DBF at file address FILE_ADR. Make
it avaliable for reuse through _gdbm_alloc. This routine changes the
avail structure. */
@@ -388,7 +386,7 @@ get_elem (int size, avail_elem av_table[], int *av_count)
/* This routine inserts a single NEW_EL into the AV_TABLE block.
This routine does no I/O. */
-int
+void
_gdbm_put_av_elem (avail_elem new_el, avail_elem av_table[], int *av_count,
int can_merge)
{
@@ -397,7 +395,7 @@ _gdbm_put_av_elem (avail_elem new_el, avail_elem av_table[], int *av_count,
/* Is it too small to deal with? */
if (new_el.av_size <= IGNORE_SIZE)
- return FALSE;
+ return;
if (can_merge == TRUE)
{
@@ -440,7 +438,7 @@ _gdbm_put_av_elem (avail_elem new_el, avail_elem av_table[], int *av_count,
}
/* we're done. */
- return TRUE;
+ return;
}
}
@@ -463,9 +461,7 @@ _gdbm_put_av_elem (avail_elem new_el, avail_elem av_table[], int *av_count,
av_table[index] = new_el;
/* Increment the number of elements. */
- *av_count += 1;
-
- return TRUE;
+ ++*av_count;
}
@@ -516,7 +512,6 @@ adjust_bucket_avail (GDBM_FILE dbf)
{
if (dbf->header->avail.count > 0)
{
- //FIXME: what if _gdbm_put_av_elem return FALSE?
dbf->header->avail.count -= 1;
av_el = dbf->header->avail.av_table[dbf->header->avail.count];
_gdbm_put_av_elem (av_el, dbf->bucket->bucket_avail,
@@ -531,14 +526,14 @@ adjust_bucket_avail (GDBM_FILE dbf)
&& dbf->header->avail.count < dbf->header->avail.size)
{
av_el = get_elem (0, dbf->bucket->bucket_avail, &dbf->bucket->av_count);
- if (av_el.av_size == 0
- || _gdbm_put_av_elem (av_el, dbf->header->avail.av_table,
- &dbf->header->avail.count,
- dbf->coalesce_blocks) == FALSE)
+ if (av_el.av_size == 0)
{
GDBM_SET_ERRNO (dbf, GDBM_BAD_AVAIL, TRUE);
return -1;
}
+ _gdbm_put_av_elem (av_el, dbf->header->avail.av_table,
+ &dbf->header->avail.count,
+ dbf->coalesce_blocks);
dbf->bucket_changed = TRUE;
}
return 0;
diff --git a/src/proto.h b/src/proto.h
index e543506..22f29e4 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -30,7 +30,7 @@ int _gdbm_write_bucket (GDBM_FILE, cache_elem *);
/* From falloc.c */
off_t _gdbm_alloc (GDBM_FILE, int);
int _gdbm_free (GDBM_FILE, off_t, int);
-int _gdbm_put_av_elem (avail_elem, avail_elem [], int *, int);
+void _gdbm_put_av_elem (avail_elem, avail_elem [], int *, int);
/* From findkey.c */
char *_gdbm_read_entry (GDBM_FILE, int);

Return to:

Send suggestions and report system problems to the System administrator.