Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

qualList.c

Go to the documentation of this file.
00001 /*
00002 ** LCLint - annotation-assisted static program checker
00003 ** Copyright (C) 1994-2000 University of Virginia,
00004 **         Massachusetts Institute of Technology
00005 **
00006 ** This program is free software; you can redistribute it and/or modify it
00007 ** under the terms of the GNU General Public License as published by the
00008 ** Free Software Foundation; either version 2 of the License, or (at your
00009 ** option) any later version.
00010 ** 
00011 ** This program is distributed in the hope that it will be useful, but
00012 ** WITHOUT ANY WARRANTY; without even the implied warranty of
00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 ** General Public License for more details.
00015 ** 
00016 ** The GNU General Public License is available from http://www.gnu.org/ or
00017 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00018 ** MA 02111-1307, USA.
00019 **
00020 ** For information on lclint: lclint-request@cs.virginia.edu
00021 ** To report a bug: lclint-bug@cs.virginia.edu
00022 ** For more information: http://lclint.cs.virginia.edu
00023 */
00024 /*
00025 ** qualList.c (from slist_template.c)
00026 */
00027 
00028 # include "lclintMacros.nf"
00029 # include "basic.h"
00030 
00031 qualList
00032 qualList_new ()
00033 {
00034   return qualList_undefined;
00035 }
00036 
00037 static /*@only@*/ /*@notnull@*/ qualList
00038 qualList_newEmpty (void)
00039 {
00040   qualList s = (qualList) dmalloc (sizeof (*s));
00041   
00042   s->nelements = 0;
00043   s->free = qualListBASESIZE;
00044   s->elements = (qual *) dmalloc (sizeof (*s->elements) * qualListBASESIZE);
00045 
00046   return (s);
00047 }
00048 
00049 void
00050 qualList_clear (qualList q)
00051 {
00052   if (qualList_isDefined (q))
00053     {
00054       q->free += q->nelements;
00055       q->nelements = 0;
00056     }
00057 }
00058 
00059 static void
00060 qualList_grow (/*@notnull@*/ qualList s)
00061 {
00062   int i;
00063   qual *oldelements = s->elements;
00064   
00065   s->free += qualListBASESIZE; 
00066 
00067   s->elements = (qual *) dmalloc (sizeof (*s->elements) * (s->nelements + s->free));
00068     
00069   for (i = 0; i < s->nelements; i++)
00070     {
00071       s->elements[i] = oldelements[i];
00072     }
00073   
00074   sfree (oldelements);
00075 }
00076 
00077 qualList qualList_add (qualList s, qual el)
00078 {
00079   if (qualList_isUndefined (s))
00080     {
00081       s = qualList_newEmpty ();
00082     }
00083   
00084   if (s->free <= 0)
00085     qualList_grow (s);
00086   
00087   s->free--;
00088   s->elements[s->nelements] = el;
00089   s->nelements++;
00090 
00091   return (s);
00092 }
00093 
00094 qualList qualList_appendList (qualList s, qualList t)
00095 {
00096   qualList_elements (t, current)
00097     {
00098       s = qualList_add (s, current);
00099     } end_qualList_elements;
00100 
00101   return s;
00102 }
00103 
00104 # ifndef NOLCL
00105 qualList qualList_copy (qualList s)
00106 {
00107   qualList t = qualList_new ();
00108 
00109   qualList_elements (s, current)
00110     {
00111       t = qualList_add (t, current);
00112     } end_qualList_elements;
00113 
00114   return t;
00115 }
00116 # endif
00117 
00118 /*@only@*/ cstring
00119 qualList_unparse (qualList s)
00120 {
00121    int i;
00122    cstring st = cstring_undefined;
00123 
00124    if (qualList_isDefined (s))
00125      {
00126        for (i = 0; i < qualList_size (s); i++)
00127          {
00128            if (i == 0)
00129              {
00130                st = message ("%q%s ", st, qual_unparse (s->elements[i]));
00131              }
00132            else
00133              st = message ("%q%s ", st, qual_unparse (s->elements[i]));
00134          }
00135      }
00136 
00137    return st;
00138 }
00139 
00140 # ifndef NOLCL
00141 /*@only@*/ cstring
00142 qualList_toCComments (qualList s)
00143 {
00144    int i;
00145    cstring st = cstring_undefined;
00146 
00147    if (qualList_isDefined (s))
00148      {
00149        for (i = 0; i < qualList_size (s); i++)
00150          {
00151            if (i == 0)
00152              {
00153                st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
00154              }
00155            else
00156              st = message ("%q/*@%s@*/ ", st, qual_unparse (s->elements[i]));
00157          }
00158      }
00159 
00160    return st;
00161 }
00162 # endif
00163 
00164 bool
00165 qualList_hasAliasQualifier (qualList s)
00166 {
00167   if (qualList_isDefined (s))
00168     {
00169       qualList_elements (s, q)
00170         {
00171           if (qual_isAliasQual (q)) return TRUE;
00172         } end_qualList_elements;
00173     }
00174 
00175   return FALSE;
00176 }
00177 
00178 bool
00179 qualList_hasExposureQualifier (qualList s)
00180 {
00181   if (qualList_isDefined (s))
00182     {
00183       qualList_elements (s, q)
00184         {
00185           if (qual_isExQual (q)) return TRUE;
00186         } end_qualList_elements;
00187     }
00188 
00189   return FALSE;
00190 }
00191 
00192 void
00193 qualList_free (/*@only@*/ qualList s)
00194 {
00195   if (qualList_isDefined (s))
00196     {
00197       sfree (s->elements); 
00198       sfree (s);
00199     }
00200 }
00201 
00202 
00203 
00204 

Generated at Fri Nov 3 18:57:43 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000