Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals  

list.c

00001  /*
00002   * plint/list.c : variables' list handling
00003   * 
00004   * Time-stamp: <2002-12-21 22:56:14 gseba>
00005   * 
00006   * Copyright (C) Sebastian Glita, email: gseba@users.sourceforge.net
00007   * 
00008   * This file is part of plint.
00009   * 
00010   * plint is free software; you can  redistribute it and/or modify it under the
00011   * terms of the  GNU General Public License as published  by the Free Software
00012   * Foundation; either version 2, or (at your option) any later version.
00013   *
00014   * plint  is distributed  in the  hope  that it  will be  useful, but  WITHOUT
00015   * ANY  WARRANTY; without  even  the implied  warranty  of MERCHANTABILITY  or
00016   * FITNESS FOR A  PARTICULAR PURPOSE.  See the GNU  General Public License for
00017   * more details.
00018   * 
00019   * You should  have received a  copy of the  GNU General Public  License along
00020   * with  plint; see  the file  COPYING.  If  not, write  to the  Free Software
00021   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA USA.
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 }

Generated on Thu Jan 9 19:02:38 2003 for plint by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002