/* ** 'clear_refs' is called to restore all the line number and case table tokens ** to their 'no address' versions. This is needed when a program is edited. ** The code also clears such tokens in installed libraries as any case tables ** built for statements in the libraries will have been put on the Basic heap. */ static void clear_refs(void) { byte *bp; library *lp; if (basicvars.runflags.has_variables) { clear_varlists(); clear_heap(); clear_strings(); } if (basicvars.runflags.has_offsets) { bp = basicvars.start; while (!AT_PROGEND(bp)) { clear_linerefs(bp); bp+=get_linelen(bp); } lp = basicvars.installist; /* Now clear the pointers in any installed libraries */ while (lp!=NIL) { bp = lp->libstart; while (!AT_PROGEND(bp)) { clear_linerefs(bp); bp = bp+GET_LINELEN(bp); } lp = lp->libflink; } } basicvars.liblist = NIL; basicvars.runflags.has_offsets = FALSE; basicvars.runflags.has_variables = FALSE; }
int g2_breadth_first_road_solver_class::path_solve(g1_team_type team, g1_road_object_class * start, g1_road_object_class * dest, g1_path_object_class * * path, w32 stack_size) { g1_road_object_class * node; i4_float len; //actually we now use exspected time clear_heap(); clear_solve(); if (!start || !dest) { return i4_F; } add_node(start, 0, 0); link_manager * lman=g2_link_man(); len=0; w32 starttime=(w32)g2_act_man()->daytime; while (get_next_node(node, len)) { //g1_road_object_class *c =0; for (int i=0; i<node->total_links(G1_ALLY); i++) //ally means outgoing { g2_link * l=lman->get_link(node->get_link_id(G1_ALLY,i)); i4_float extime=l->quratio(starttime,len); //i4_float extime=l->get_length()/l->get_freespeed(); add_node((g1_road_object_class *)node->get_link(G1_ALLY,i), node, len + extime); //else we skip. } } w32 points=0; if (dest->ref==0) { return 0; } // count nodes node = dest; points = 0; while (node!=start&&points<(stack_size)) { /*point[points*2+0] = i4_float(graph->critical[node].x)+0.5f; point[points*2+1] = i4_float(graph->critical[node].y)+0.5f; points++; node = solve_graph[node].ref;*/ path[points++]=node; node=node->ref; } path[points++]=start; //it seems paths need this entry to work correctly //point[points*2+0] = i4_float(graph->critical[start_node].x)+0.5f; //point[points*2+1] = i4_float(graph->critical[start_node].y)+0.5f; //points++; return points; }
/* ** 'clear_program' is called when a 'NEW' command is issued to clear the old ** program from memory. The start of an existing program is preserved in ** 'oldstart' in case 'OLD' is used so that the old program can be restored ** to health */ void clear_program(void) { clear_varlists(); clear_strings(); clear_heap(); basicvars.start = basicvars.top = basicvars.page+MARKERSIZE; memmove(basicvars.page, startmark, STARTMARKSIZE); preserve(); /* Preserve the start of program in memory (if any) */ mark_end(basicvars.top); basicvars.lomem = basicvars.vartop = basicvars.top+ENDMARKSIZE; basicvars.stacklimit.bytesp = basicvars.top+STACKBUFFER; basicvars.stacktop.bytesp = basicvars.himem; basicvars.lastsearch = basicvars.start; basicvars.procstack = NIL; basicvars.liblist = NIL; basicvars.error_line = 0; basicvars.error_number = 0; basicvars.error_handler.current = NIL; basicvars.escape = FALSE; basicvars.misc_flags.badprogram = FALSE; basicvars.runflags.running = FALSE; basicvars.runflags.has_offsets = FALSE; basicvars.runflags.has_variables = FALSE; basicvars.runflags.closefiles = TRUE; basicvars.runflags.make_array = FALSE; basicvars.tracehandle = 0; basicvars.traces.lines = FALSE; basicvars.traces.pause = FALSE; basicvars.traces.procs = FALSE; basicvars.traces.branches = FALSE; basicvars.traces.backtrace = TRUE; basicvars.staticvars[ATPERCENT].varentry.varinteger = STDFORMAT; basicvars.curcount = 0; basicvars.printcount = 0; basicvars.printwidth = DEFWIDTH; basicvars.program[0] = NUL; basicvars.linecount = 0; last_added = NIL; init_stack(); }
/* ** 'recover_program' is called to verify that the program at 'page' ** is legal. It resets the various program pointers if it is, or ** flags the program as invalid if not (after resetting the various ** pointer to 'safe' values) */ void recover_program(void) { byte *bp = NULL; if (basicvars.misc_flags.validsaved) { /* Only check if the command 'new' has been used */ reinstate(); /* Restore start of program */ bp = basicvars.start; basicvars.misc_flags.validsaved = isvalidprog(); } if (basicvars.misc_flags.validsaved) { /* Old program is okay */ while (!AT_PROGEND(bp)) bp+=get_linelen(bp); /* Find end */ basicvars.top = bp; adjust_heaplimits(); } else { /* Program is not valid - Ensure everything is set to safe values */ clear_varlists(); clear_strings(); clear_heap(); basicvars.misc_flags.badprogram = TRUE; save_lineno(basicvars.start, ENDLINENO); basicvars.current = basicvars.datacur = basicvars.top = basicvars.page+MARKERSIZE; adjust_heaplimits(); error(ERR_BADPROG); } }
player::~player() { // Clean up gameswf as much as possible, so valgrind will help find actual leaks. // Maximum release of resources. Calls clear_library() and // fontlib::clear(), and also clears some extra internal stuff // that may have been allocated (e.g. global ActionScript // objects). This should get all gameswf structures off the // heap, with the exception of any objects that are still // referenced by the host program and haven't had drop_ref() // called on them. m_current_root = NULL; m_global = NULL; --s_player_count; clear_heap(); gameswf_engine_mutex().lock(); clear_library(); // Clear shared stuff only when all players are deleted if (s_player_count == 0) { clears_tag_loaders(); clear_shared_libs(); clear_registered_type_handlers(); clear_standard_method_map(); clear_disasm(); delete s_glyph_provider; s_glyph_provider = NULL; } gameswf_engine_mutex().unlock(); action_clear(); }
void sml_heap_gc(void) { #ifdef GCTIME sml_timer_t b_start, b_end; sml_time_t gctime; //#endif /* GCTIME */ //#ifdef GCSTAT sml_time_t cleartime,t; sml_timer_t b_cleared; #endif /* GCSTAT */ #ifdef GCSTAT if (gcstat.verbose >= GCSTAT_VERBOSE_COUNT) { stat_notice("---"); stat_notice("event: start gc"); if (gcstat.last.trigger) stat_notice("trigger: %u", gcstat.last.trigger); print_alloc_count(); print_heap_occupancy(); } clear_last_counts(); #endif /* GCSTAT */ DBG(("start gc")); #ifdef GCTIME gcstat.gc.count++; sml_timer_now(b_start); #endif /* GCTIME */ #ifdef PRINT_ALLOC_TIME live_tmp = 0; count_gc++; double st; getRusage(st); #endif /* PRINT_ALLOC_TIME */ all_bitmaps_space_clear(); #ifdef GCTIME//GCSTAT sml_timer_now(b_cleared); #endif /* GCSTAT */ #ifdef PRINT_ALLOC_TIME double en; getRusage(en); all_time_bit_clear += (en - st); #endif /* PRINT_ALLOC_TIME */ /* mark root objects */ sml_rootset_enum_ptr(mark, MAJOR); DBG(("marking root objects completed")); /* STACK POP */ while (marking_stack.bottom != marking_stack.top) { marking_stack.top--; mark_children((*(marking_stack.top))); } sml_malloc_pop_and_mark(mark_all, MAJOR); DBG(("marking completed")); #ifdef CHECK clear_heap(); #endif /* CHECK */ /* check finalization */ sml_check_finalizer(mark_all, MAJOR); /* sweep malloc heap */ sml_malloc_sweep(MAJOR); #ifdef GCTIME sml_timer_now(b_end); #endif /* GCTIME */ DBG(("gc finished.")); #ifdef GCTIME sml_timer_dif(b_start, b_end, gctime); sml_time_accum(gctime, gcstat.gc.total_time); sml_timer_dif(b_start, b_cleared, cleartime); sml_time_accum(cleartime, gcstat.gc.clear_time); #endif #ifdef GCSTAT if (gcstat.verbose >= GCSTAT_VERBOSE_GC) { sml_timer_dif(gcstat.exec_begin, b_start, t); stat_notice("time: "TIMEFMT, TIMEARG(t)); stat_notice("---"); stat_notice("event: end gc"); sml_timer_dif(gcstat.exec_begin, b_end, t); stat_notice("time: "TIMEFMT, TIMEARG(t)); stat_notice("duration: "TIMEFMT, TIMEARG(gctime)); stat_notice("clear_time: "TIMEFMT, TIMEARG(cleartime)); stat_notice("clear_bytes: %lu", gcstat.last.clear_bytes); stat_notice("push: %u", gcstat.last.push_count); stat_notice("trace: %u", gcstat.last.trace_count); print_heap_occupancy(); } #endif /* GCSTAT */ #ifdef PRINT_ALLOC_TIME if(live_tmp > live_max) live_max = live_tmp; if(live_tmp < live_min) live_min = live_tmp; live_all += live_tmp; unsigned int i; for(i=0; i<THE_NUMBER_OF_FIXED_BLOCK; i++) { if(((print_info[i].count_mark - print_info[i].tmp_mark) * print_info[i].block_size) > print_info[i].max_live) print_info[i].max_live = ((print_info[i].count_mark - print_info[i].tmp_mark) * print_info[i].block_size); print_info[i].tmp_mark=print_info[i].count_mark; } #endif /* PRINT_ALLOC_TIME */ /* start finalizers */ sml_run_finalizer(NULL); }