00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "plint.h"
00026 #include "error.h"
00027 #include "share.h"
00028
00029 #include "data.h"
00030 #include "list.h"
00031
00032 static void var_free(hashindex_t name
00033 #ifdef PLINT_VERB_WARN
00034 , int touch, plint_tree_t proc, int level
00035 #endif
00036 )
00037 {
00038 #ifdef PLINT_VERB_WARN
00039 if (plint_verbose && !p->touch)
00040 {
00041 char * var = hash_getstr(plint_hash, p->name, 0);
00042
00043 eprintf("\n%s%s%s\"%s\" %s#%d %s ", PLINT_PLINT, PLINT_WARN, PLINT_TOUCH, var, PLINT_LEVEL, level, PLINT_PRME(proc));
00044 plint_proc_log(stderr, proc);
00045 free(var);
00046 }
00047 #endif
00048
00049 hash_remstr(plint_hash.id, name);
00050 }
00051
00052 void plint_list_free(plint_stack_t s, plint_list_t * p, size_t c)
00053 {
00054 plint_list_t l;
00055
00056 while (l = *p, c--)
00057 {
00058 plint_mem_t mem = l->var;
00059 *p = l->next;
00060
00061 plint_trace(var, 1, l);
00062
00063 var_free(l->name
00064 #ifdef PLINT_VERB_WARN
00065 l->touch, l->home->proc->block.src, l->home->block.src->level - l->home->proc->block.src->level
00066 #endif
00067 );
00068 free(l);
00069 plint_mem_fre(mem);
00070 }
00071 }
00072
00073 plint_list_t plint_list_1st(plint_stack_t s)
00074 {
00075 switch (s->block.src->frm)
00076 {
00077 case PLINT_FRM_METH:
00078 return s->head->next->next;
00079 default:
00080 return s->head->next;
00081 }
00082 }
00083
00084 plint_list_t plint_list_nth(plint_stack_t s, size_t n)
00085 {
00086 plint_list_t l = plint_list_1st(s);
00087 while (--n && l)
00088 l = l->next;
00089 return l;
00090 }
00091
00092 void plint_list_ite(plint_stack_t s, void (* f)(plint_list_t, void *), void * p)
00093 {
00094 plint_list_t l;
00095 for (l = plint_list_1st(s); l; l = l->next)
00096 f(l, p);
00097 }