Changeset: 19bff24d9d93 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/19bff24d9d93
Modified Files:
gdk/gdk_utils.c
monetdb5/mal/mal_instruction.c
Branch: resource_management
Log Message:
propagate forgotten instr_allocator on copy mal blk
diffs (77 lines):
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2089,6 +2089,8 @@ eb_error(exception_buffer *eb, const cha
#define SA_BLOCK_SIZE (128*1024)
#define SA_HEADER_SIZE 2*(sizeof(size_t))
#define CANARY_VALUE ((size_t)0xDEADBEEFDEADBEEF)
+#define round16(sz) ((sz+15)&~15)
+#define round_block_size(sz) ((sz + (SA_BLOCK_SIZE - 1))&~(SA_BLOCK_SIZE - 1))
typedef struct freed_t {
size_t sz;
@@ -2240,7 +2242,7 @@ allocator *sa_reset(allocator *sa)
sa->frees = 0;
sa->nr = 1;
- sa->used = 0;
+ sa->used = sa->pa ? round16(sizeof(allocator)) : 0;
sa->freelist = NULL;
sa->freelist_blks = NULL;
sa->usedmem = SA_BLOCK_SIZE;
@@ -2274,8 +2276,6 @@ sa_realloc(allocator *sa, void *p, size_
return r;
}
-#define round16(sz) ((sz+15)&~15)
-#define round_block_size(sz) ((sz + (SA_BLOCK_SIZE - 1))&~(SA_BLOCK_SIZE - 1))
static void *
_sa_alloc_internal(allocator *sa, size_t sz)
{
@@ -2382,7 +2382,7 @@ create_allocator(allocator *pa)
sa->freelist = NULL;
sa->freelist_blks = NULL;
sa->frees = 0;
- sa->used = 0;
+ sa->used = (pa)? round16(sizeof(allocator)) : 0;
sa->objects = 0;
sa->inuse = 0;
sa->free_obj_hits = 0;
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -316,6 +316,7 @@ copyMalBlk(MalBlkPtr old)
}
mb->ma = ma;
+ mb->instr_allocator = ma_create(ma);
mb->var = MA_ZNEW_ARRAY(ma, VarRecord, old->vsize);
if (mb->var == NULL) {
ma_destroy(ma);
@@ -442,7 +443,7 @@ copyInstructionArgs(MalBlkPtr mb, const
{
if (args < p->maxarg)
args = p->maxarg;
- InstrPtr new = (InstrPtr) MA_NEW_ARRAY(mb->ma, char,
offsetof(InstrRecord, argv) + args * sizeof(p->argv[0]));
+ InstrPtr new = (InstrPtr) MA_NEW_ARRAY(mb->instr_allocator, char,
offsetof(InstrRecord, argv) + args * sizeof(p->argv[0]));
if (new == NULL)
return new;
memcpy(new, p, offsetof(InstrRecord, argv) + p->maxarg *
sizeof(p->argv[0]));
@@ -480,7 +481,7 @@ clrInstruction(InstrPtr p)
void
freeInstruction(MalBlkPtr mb, InstrPtr p)
{
- assert(p && mb && mb->ma);
+ assert(p && mb && mb->instr_allocator);
sa_free(mb->instr_allocator, p);
}
@@ -992,7 +993,7 @@ extendInstruction(MalBlkPtr mb, InstrPtr
InstrPtr pn = p;
if (p->argc == p->maxarg) {
int space = p->maxarg * sizeof(p->argv[0]) +
offsetof(InstrRecord, argv);
- pn = (InstrPtr) MA_RENEW_ARRAY(mb->ma, char, p, space + MAXARG
* sizeof(p->argv[0]), space);
+ pn = (InstrPtr) MA_RENEW_ARRAY(mb->instr_allocator, char, p,
space + MAXARG * sizeof(p->argv[0]), space);
if (pn == NULL) { /* In the exceptional case we
can not allocate more space * then we show an exception, mark the block as
erroneous * and leave the instruction as is. */
mb->errors = createMalException(mb, 0, TYPE,
SQLSTATE(HY013) MAL_MALLOC_FAIL);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]