Skip to content
Snippets Groups Projects
Commit 6c9df3fb authored by Stephan Wirth's avatar Stephan Wirth
Browse files

changed check for MAX_CONTEXTS order and added check in print loop

parent 28f9c9f3
No related branches found
No related tags found
No related merge requests found
...@@ -99,18 +99,19 @@ void egsl_push_named(const char*name) { ...@@ -99,18 +99,19 @@ void egsl_push_named(const char*name) {
egsl_first_time = 0; egsl_first_time = 0;
} }
cid++; cid++;
if(max_cid < cid) max_cid = cid;
if(name != 0)
sprintf(egsl_contexts[cid].name, "%s", name);
else
sprintf(egsl_contexts[cid].name, "Unnamed context");
if(cid >= MAX_CONTEXTS) { if(cid >= MAX_CONTEXTS) {
fprintf(stderr, "egsl: maximum number of contexts reached \n"); fprintf(stderr, "egsl: maximum number of contexts reached \n");
egsl_print_stats(); egsl_print_stats();
assert(0); assert(0);
} }
if(max_cid < cid) max_cid = cid;
if(name != 0)
sprintf(egsl_contexts[cid].name, "%s", name);
else
sprintf(egsl_contexts[cid].name, "Unnamed context");
} }
void egsl_pop_named(const char*name) { void egsl_pop_named(const char*name) {
...@@ -147,7 +148,7 @@ void egsl_print_stats() { ...@@ -147,7 +148,7 @@ void egsl_print_stats() {
fprintf(stderr, "egsl: total allocations: %d cache hits: %d\n", fprintf(stderr, "egsl: total allocations: %d cache hits: %d\n",
egsl_total_allocations, egsl_cache_hits); egsl_total_allocations, egsl_cache_hits);
/* printf("egsl: sizeof(val) = %d\n",(int)sizeof(val)); */ /* printf("egsl: sizeof(val) = %d\n",(int)sizeof(val)); */
int c; for(c=0;c<=max_cid;c++) { int c; for(c=0;c<=max_cid&&c<MAX_CONTEXTS;c++) {
/* printf("egsl: context #%d\n ",c); */ /* printf("egsl: context #%d\n ",c); */
/* if(0==egsl_contexts[c].nallocated) break; */ /* if(0==egsl_contexts[c].nallocated) break; */
fprintf(stderr, "egsl: context #%d allocations: %d active: %d name: '%s' \n", fprintf(stderr, "egsl: context #%d allocations: %d active: %d name: '%s' \n",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment