Changeset: 0d83403cb429 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0d83403cb429 Modified Files: gdk/gdk_utils.c monetdb5/mal/mal_profiler.c monetdb5/optimizer/opt_emptybind.c monetdb5/optimizer/opt_generator.c monetdb5/optimizer/opt_inline.c monetdb5/optimizer/opt_pipes.c Branch: resource_management Log Message:
cannot use temp allocator for globals diffs (170 lines): diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -2217,8 +2217,6 @@ sa_create(allocator *pa) sa->size = SA_NUM_BLOCKS; sa->nr = 1; sa->blks = pa?(char**)sa_alloc(pa, sizeof(char*) * sa->size):(char**)GDKmalloc(sizeof(char*) * sa->size); - sa->freelist = NULL; - sa->freelist_blks = NULL; if (sa->blks == NULL) { if (!pa) GDKfree(sa); @@ -2233,6 +2231,8 @@ sa_create(allocator *pa) GDKfree(sa); return NULL; } + sa->freelist = NULL; + sa->freelist_blks = NULL; sa->used = 0; sa->objects = 0; sa->inuse = 0; @@ -2354,6 +2354,8 @@ void sa_destroy( allocator *sa ) if (sa->pa) { sa_reset(sa); sa_free_blk(sa->pa, sa->blks[0]); + // TODO free sa object from parent + sa_free_obj(sa->pa, sa, sizeof(allocator)); return; } // root allocator diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -266,9 +266,9 @@ format_val2json(const Client c, const Va return buf; ValRecord val; - /* TODO use ta */ - ma_open(c->ta); - if (VALinit(c->ta, &val, TYPE_str, buf) == NULL) { + /* NOTE c->ta maybe active from caller */ + allocator *ta = (c->ta && c->ta->tmp_active) ? c->ta : NULL; + if (VALinit(ta, &val, TYPE_str, buf) == NULL) { GDKfree(buf); return NULL; } @@ -278,7 +278,6 @@ format_val2json(const Client c, const Va char *buf2; buf2 = VALformat(&val); VALclear(&val); - ma_close(c->ta); return buf2; } diff --git a/monetdb5/optimizer/opt_emptybind.c b/monetdb5/optimizer/opt_emptybind.c --- a/monetdb5/optimizer/opt_emptybind.c +++ b/monetdb5/optimizer/opt_emptybind.c @@ -71,8 +71,10 @@ OPTemptybindImplementation(Client cntxt, // empty = (int *) GDKzalloc((mb->vsize + extras) * sizeof(int)); ma_open(cntxt->ta); empty = (int *) ma_zalloc(cntxt->ta, (mb->vsize + extras) * sizeof(int)); - if (empty == NULL) + if (empty == NULL) { + ma_close(cntxt->ta); throw(MAL, "optimizer.emptybind", SQLSTATE(HY013) MAL_MALLOC_FAIL); + } // updated = (InstrPtr *) GDKzalloc(esize * sizeof(InstrPtr)); size_t updated_size = esize * sizeof(InstrPtr); diff --git a/monetdb5/optimizer/opt_generator.c b/monetdb5/optimizer/opt_generator.c --- a/monetdb5/optimizer/opt_generator.c +++ b/monetdb5/optimizer/opt_generator.c @@ -208,12 +208,12 @@ OPTgeneratorImplementation(Client cntxt, } for (; i < limit; i++) pushInstruction(mb, old[i]); - ma_close(cntxt->ta); bailout: for (; i < slimit; i++) { if (old[i]) pushInstruction(mb, old[i]); } + ma_close(cntxt->ta); //GDKfree(old); /* Defense line against incorrect plans */ diff --git a/monetdb5/optimizer/opt_inline.c b/monetdb5/optimizer/opt_inline.c --- a/monetdb5/optimizer/opt_inline.c +++ b/monetdb5/optimizer/opt_inline.c @@ -31,6 +31,7 @@ inlineMALblock(Client cntxt, MalBlkPtr m nv = (int *) ma_alloc(cntxt->ta, mc->vtop * sizeof(int)); if (nv == 0) { //GDKfree(ns); + ma_close(cntxt->ta); return -1; } diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c --- a/monetdb5/optimizer/opt_pipes.c +++ b/monetdb5/optimizer/opt_pipes.c @@ -306,11 +306,10 @@ addPipeDefinition(Client cntxt, const ch SQLSTATE(42000) "No overwrite of built in allowed"); } - ma_open(cntxt->ta); /* save old value */ oldpipe = pipes[i]; pipes[i] = (struct pipeline) { - .name = MA_STRDUP(cntxt->ta, name), + .name = GDKstrdup(name), }; if (pipes[i].name == NULL) goto bailout; @@ -319,7 +318,7 @@ addPipeDefinition(Client cntxt, const ch p++; n++; } - if ((pipes[i].def = ma_alloc(cntxt->ta, n * sizeof(char *))) == NULL) + if ((pipes[i].def = GDKmalloc(n * sizeof(char *))) == NULL) goto bailout; n = 0; while ((p = strchr(pipe, ';')) != NULL) { @@ -334,7 +333,7 @@ addPipeDefinition(Client cntxt, const ch goto bailout; } if (q > pipe) { - if ((pipes[i].def[n++] = MA_STRNDUP(cntxt->ta, pipe, q - pipe)) == NULL) + if ((pipes[i].def[n++] = GDKstrndup(pipe, q - pipe)) == NULL) goto bailout; } pipe = p + 1; @@ -354,16 +353,14 @@ addPipeDefinition(Client cntxt, const ch for (n = 0; oldpipe.def[n]; n++) GDKfree(oldpipe.def[n]); GDKfree(oldpipe.def); - ma_close(cntxt->ta); return msg; bailout: - //GDKfree(pipes[i].name); - //if (pipes[i].def) - // for (n = 0; pipes[i].def[n]; n++) - // GDKfree(pipes[i].def[n]); - //GDKfree(pipes[i].def); - ma_close(cntxt->ta); + GDKfree(pipes[i].name); + if (pipes[i].def) + for (n = 0; pipes[i].def[n]; n++) + GDKfree(pipes[i].def[n]); + GDKfree(pipes[i].def); pipes[i] = oldpipe; MT_lock_unset(&pipeLock); if (msg) @@ -490,11 +487,11 @@ opt_pipes_reset(void) { for (int i = 0; i < MAXOPTPIPES; i++) if (pipes[i].name && !pipes[i].builtin) { - //GDKfree(pipes[i].name); - //if (pipes[i].def) - // for (int n = 0; pipes[i].def[n]; n++) - // GDKfree(pipes[i].def[n]); - //GDKfree(pipes[i].def); + GDKfree(pipes[i].name); + if (pipes[i].def) + for (int n = 0; pipes[i].def[n]; n++) + GDKfree(pipes[i].def[n]); + GDKfree(pipes[i].def); pipes[i] = (struct pipeline) { .name = NULL, }; _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org