void *fn_static(void *param) { var_static *= 2; shared_check(); usleep(1); // thread breakpoint for(;;) usleep(1); }
void motopp_freeEnv(MotoPP *ppenv) { Enumeration *e; log_debug(__FILE__, ">>> motopp_freeEnv\n"); buf_free(ppenv->out); buf_free(ppenv->err); buf_free(ppenv->argbuf); istack_free(ppenv->dirstack); stack_free(ppenv->frames); /* free vals */ e = hset_elements(ppenv->vallist); while (enum_hasNext(e)) { MotoPPVal *val = enum_next(e); if (shared_check(val->sval)) { free(val->sval); hset_remove(ppenv->ptrs, val->sval); } free(val); } enum_free(e); hset_free(ppenv->vallist); /* free macros */ while (stack_size(ppenv->macrostack) > 0) { SymbolTable *macros = stack_pop(ppenv->macrostack); e = stab_getKeys(macros); while (enum_hasNext(e)) { char *name = (char *)enum_next(e); MotoMacro *m = (MotoMacro *)stab_get(macros, name); motopp_freeMacro(m); } stab_free(macros); enum_free(e); } /* free all remaining sys pointers */ e = hset_elements(ppenv->sysptrs); while (enum_hasNext(e)) { void *ptr = enum_next(e); if (ptr) { sys_free(ptr); } } enum_free(e); /* free all remaining pointers */ e = hset_elements(ppenv->ptrs); while (enum_hasNext(e)) { void *ptr = enum_next(e); if (shared_check(ptr)) { free(ptr); } } enum_free(e); /* free remaining pooled memory */ mpool_free(ppenv->mpool); /* free remainder of env struct */ hset_free(ppenv->sysptrs); hset_free(ppenv->ptrs); stack_free(ppenv->macrostack); free(ppenv); log_debug(__FILE__, "<<< motopp_freeEnv\n"); }
void motopp_freeFrame(MotoPP *ppenv) { MotoPPFrame *frame; Enumeration *e; if (stack_size(ppenv->frames) <= 1) { frame = stack_pop(ppenv->frames); buf_cat(ppenv->out, frame->out); ppenv->frame = NULL; } else { MotoPPVal *val; MotoPPFrame *pframe; SymbolTable *macros; MotoMacro *m; char *catstr; int catstrlen; frame = stack_pop(ppenv->frames); pframe = stack_peek(ppenv->frames); switch (frame->type) { case MACRO_FRAME: m = frame->macro; val = motopp_createVal(ppenv); if (ppenv->flags & MACRO_DEBUG_FLAG) { buf_printf(frame->out, LINE_FMT_2, pframe->filename, pframe->lineno); } val->sval = buf_toString(frame->out); stack_push(pframe->opstack, val); macros = stack_pop(ppenv->macrostack); e = stab_getKeys(macros); while (enum_hasNext(e)) { char *name = (char *)enum_next(e); MotoMacro *m = (MotoMacro *)stab_get(macros, name); motopp_freeMacro(m); } stab_free(macros); enum_free(e); break; case INCLUDE_FRAME: catstr = buf_data(frame->out); catstrlen = strlen(catstr); if (catstr[catstrlen - 1] == '\n') { catstr[catstrlen - 1] = '\0'; } buf_puts(pframe->out, catstr); if (ppenv->flags & MACRO_DEBUG_FLAG) { buf_printf(pframe->out, LINE_FMT_2, pframe->filename, pframe->lineno); } break; default: buf_cat(pframe->out, frame->out); break; } /* reset pplineno */ pplineno = pframe->lineno; /* reset frame */ ppenv->frame = pframe; } if (frame->yybuf != NULL) { if (shared_check(frame->yybuf)) { motopp_freeYYBuffer(frame->yybuf); } } if (frame->yybufmem != NULL) { free(frame->yybufmem); } buf_free(frame->out); stack_free(frame->opstack); free(frame->filename); free(frame->relative_root); free(frame); }
void moto_freeEnv(MotoEnv *env) { Enumeration *e; /* Free any outstanding frames */ while(vec_size(env->frames) > 0) { moto_freeFrame(env); } /* Free all the globals */ e = stab_getKeys(env->globals); while (enum_hasNext(e)) { char* n = (char*)enum_next(e); MotoVar* var = stab_get(env->globals,n); if(env->mode != COMPILER_MODE) { moto_freeVal(env,var->vs); } else { opool_release(env->valpool,var->vs); } free(var); } enum_free(e); stab_free(env->globals); /* free all cached regular expressions */ e = stab_getKeys(env->rxcache); while (enum_hasNext(e)) { char *rx = (char *)enum_next(e); MDFA *mdfa = (MDFA *)stab_get(env->rxcache, rx); if (mdfa != NULL) { mdfa_free(mdfa); } } enum_free(e); /* free all remaining pointers */ e = hset_elements(env->ptrs); while (enum_hasNext(e)) { void *ptr = enum_next(e); if (shared_check(ptr)) { free(ptr); } } enum_free(e); /* free all errors */ e = sset_elements(env->errs); while (enum_hasNext(e)) { void *ptr = enum_next(e); if (shared_check(ptr)) { free(ptr); } } enum_free(e); /* free all scopes */ e = stack_elements(env->scope); while (enum_hasNext(e)) { free(enum_next(e)); } enum_free(e); /* free all cells */ moto_freeTreeCells(env); /* free all class defs */ stab_free(env->cdefs); /* free remainder of env struct */ hset_free(env->ptrs); buf_free(env->out); buf_free(env->err); stab_free(env->types); vec_free(env->frames); ftab_free(env->ftable); /* Free all the stuff that got put in the mpool ... this includes MotoFunctions and MotoClassDefinitions */ mpool_free(env->mpool); stack_free(env->scope); stab_free(env->rxcache); //stack_free(env->callstack); sset_free(env->errs); sset_free(env->uses); sset_free(env->includes); buf_free(env->fcodebuffer); istack_free(env->scopeIDStack); htab_free(env->fdefs); htab_free(env->adefs); buf_free(env->constantPool); moto_freeTree(env->tree); opool_free(env->valpool); opool_free(env->bufpool); opool_free(env->stkpool); e = stab_getKeys(env->fcache); while (enum_hasNext(e)) free((char *)enum_next(e)); enum_free(e); stab_free(env->fcache); free(env); }