Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.89
 
1.90
 
MAIN:ragge:20080810144930
 
cpp.c
_>8383 #include <time.h>
 8484 #include <ctype.h>
 8585 
<>86 -#ifdef HAVE_ALLOCA_H
 87 -#include <alloca.h>
 88 -#endif
 89 -#ifdef HAVE_MALLOC_H
 90 -#include <malloc.h>
 91 -#endif
 92 -
9386 #include "compat.h"
 9487 #include "cpp.h"
 9588 #include "y.tab.h"
     
 !
178171 void line(void);
 179172 void flbuf(void);
 180173 void usage(void);
<> 174+usch *xstrdup(char *str);
181175 
<> 176+
182177 int
 183178 main(int argc, char **argv)
 184179 {
     
 !
630625         int c, i, redef;
 631626         int mkstr = 0, narg = -1;
 632627         int ellips = 0;
<>633 -        size_t len;
634628 #ifdef GCC_VARI
 635629         usch *gccvari = NULL;
 636630 #endif
     
 !
668662                                         if (!strcmp((char *) args[i], yytext))
 669663                                                 error("Duplicate macro "
 670664                                                   "parameter \"%s\"", yytext);
<>671 -                                len = strlen(yytext);
 672 -                                args[narg] = alloca(len+1);
 673 -                                strlcpy((char *)args[narg], yytext, len+1);
 674 -                                narg++;
  665+                                args[narg++] = xstrdup(yytext);
675666                                 if ((c = definp()) == ',') {
 676667                                         if ((c = definp()) == ')')
 677668                                                 goto bad;
     
 !
841832         }
 842833 #endif
 843834         slow = 0;
<> 835+        for (i = 0; i < narg; i++)
  836+                free(args[i]);
844837         return;
 845838 
 846839 bad:    error("bad define");
     
 !
10471040         struct symtab *nl;
 10481041         int c, noexp = 0, orgexp;
 10491042         usch *och, *stksv;
<>1050 -        extern int yyleng;
10511043 
 10521044 #ifdef CPP_DEBUG
 10531045         if (dflag) {
     
 !
11521144                                 error("bad noexp %d", noexp);
 11531145                         stksv = NULL;
 11541146                         if ((c = yylex()) == WSPACE) {
<>1155 -                                stksv = alloca(yyleng+1);
 1156 -                                strlcpy((char *)stksv, yytext, yyleng+1);
  1147+                                stksv = xstrdup(yytext);
11571148                                 c = yylex();
 11581149                         }
 11591150                         /* only valid for expansion if fun macro */
     
 !
11701161                                         unpstr(stksv);
 11711162                                 savstr(nl->namep);
 11721163                         }
<> 1164+                        if (stksv)
  1165+                                free(stksv);
11731166                         break;
 11741167 
 11751168                 case CMNT:
     
 !
12221215                 ellips = 1;
 12231216         } else
 12241217                 narg = vp[1];
<>1225 -        args = alloca(sizeof(usch *) * (narg+ellips));
  1218+        if ((args = malloc(sizeof(usch *) * (narg+ellips))) == NULL)
  1219+                error("expdef: out of mem");
12261220 
 12271221         /*
 12281222          * read arguments and store them on heap.
     
 !
13761370 
 13771371         /* scan the input buffer (until WARN) and save result on heap */
 13781372         expmac(rp);
<> 1373+        free(args);
13791374 }
 13801375 
 13811376 usch *
     
 !
16641659         return (struct symtab *)new->lr[bit];
 16651660 }
 16661661 
<_ 1662+usch *
  1663+xstrdup(char *str)
  1664+{
  1665+        size_t len = strlen(str)+1;
  1666+        usch *rv;
  1667+
  1668+        if ((rv = malloc(len)) == NULL)
  1669+                error("xstrdup: out of mem");
  1670+        strlcpy((char *)rv, str, len);
  1671+        return rv;
  1672+}
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-17 13:33 +0200