Changeset: edfce97f97a0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/edfce97f97a0
Modified Files:
gdk/gdk_bbp.c
Branch: Jul2021
Log Message:
Cleanup + plug unlikely memory leak.
diffs (53 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -518,32 +518,32 @@ vheapinit(BAT *b, const char *buf, int h
uint16_t storage;
if (b->tvarsized && b->ttype != TYPE_void) {
- b->tvheap = GDKzalloc(sizeof(Heap));
- if (b->tvheap == NULL) {
- TRC_CRITICAL(GDK, "cannot allocate memory for heap.");
- return -1;
- }
if (sscanf(buf,
" %" SCNu64 " %" SCNu64 " %" SCNu16
"%n",
&free, &size, &storage, &n) < 3) {
TRC_CRITICAL(GDK, "invalid format for BBP.dir on line
%d", lineno);
- GDKfree(b->theap);
- b->tvheap = NULL;
+ return -1;
+ }
+ b->tvheap = GDKmalloc(sizeof(Heap));
+ if (b->tvheap == NULL) {
+ TRC_CRITICAL(GDK, "cannot allocate memory for heap.");
return -1;
}
- b->tvheap->free = (size_t) free;
- b->tvheap->size = (size_t) size;
- b->tvheap->base = NULL;
+ *b->tvheap = (Heap) {
+ .free = (size_t) free,
+ .size = (size_t) size,
+ .base = NULL,
+ .storage = (storage_t) storage,
+ .hashash = hashash != 0,
+ .cleanhash = true,
+ .newstorage = (storage_t) storage,
+ .dirty = false,
+ .parentid = bid,
+ .farmid = BBPselectfarm(PERSISTENT, b->ttype, varheap),
+ };
strconcat_len(b->tvheap->filename, sizeof(b->tvheap->filename),
filename, ".theap", NULL);
- b->tvheap->storage = (storage_t) storage;
- b->tvheap->hashash = hashash != 0;
- b->tvheap->cleanhash = true;
- b->tvheap->newstorage = (storage_t) storage;
- b->tvheap->dirty = false;
- b->tvheap->parentid = bid;
- b->tvheap->farmid = BBPselectfarm(PERSISTENT, b->ttype,
varheap);
ATOMIC_INIT(&b->tvheap->refs, 1);
if (b->tvheap->free > b->tvheap->size) {
TRC_CRITICAL(GDK, "\"free\" value larger than \"size\"
in var heap of bat %d on line %d\n", (int) bid, lineno);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list