ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/readfargs.c
(Generate patch)

Comparing ray/src/common/readfargs.c (file contents):
Revision 2.6 by gwlarson, Tue Aug 25 10:20:30 1998 UTC vs.
Revision 2.8 by greg, Tue Feb 25 02:47:21 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Allocate, read and free object arguments
6   */
7  
8 + #include "copyright.h"
9 +
10   #include "standard.h"
11  
12   #include "object.h"
13  
14  
16 #ifndef  MEMHOG
17 #define  bmalloc        malloc
18 #endif
15  
16 < extern char  *fgetword();
21 < extern int  atoi();
22 < extern long  atol();
23 <
24 <
16 > int
17   readfargs(fa, fp)               /* read function arguments from stream */
18   register FUNARGS  *fa;
19   FILE  *fp;
# Line 35 | Line 27 | FILE  *fp;
27          if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
28                  return(0);
29          if (fa->nsargs = n) {
30 <                fa->sarg = (char **)bmalloc(n*sizeof(char *));
30 >                fa->sarg = (char **)malloc(n*sizeof(char *));
31                  if (fa->sarg == NULL)
32                          return(-1);
33                  for (i = 0; i < fa->nsargs; i++) {
# Line 49 | Line 41 | FILE  *fp;
41                  return(0);
42   #ifdef  IARGS
43          if (fa->niargs = n) {
44 <                fa->iarg = (long *)bmalloc(n*sizeof(long));
44 >                fa->iarg = (long *)malloc(n*sizeof(long));
45                  if (fa->iarg == NULL)
46                          return(-1);
47                  for (i = 0; i < n; i++) {
# Line 66 | Line 58 | FILE  *fp;
58          if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
59                  return(0);
60          if (fa->nfargs = n) {
61 <                fa->farg = (FLOAT *)bmalloc(n*sizeof(FLOAT));
61 >                fa->farg = (FLOAT *)malloc(n*sizeof(FLOAT));
62                  if (fa->farg == NULL)
63                          return(-1);
64                  for (i = 0; i < n; i++) {
# Line 83 | Line 75 | FILE  *fp;
75   }
76  
77  
78 < #ifndef  MEMHOG
78 > void
79   freefargs(fa)                   /* free object arguments */
80   register FUNARGS  *fa;
81   {
# Line 92 | Line 84 | register FUNARGS  *fa;
84          if (fa->nsargs) {
85                  for (i = 0; i < fa->nsargs; i++)
86                          freestr(fa->sarg[i]);
87 <                free((char *)fa->sarg);
87 >                free((void *)fa->sarg);
88 >                fa->sarg = NULL;
89 >                fa->nsargs = 0;
90          }
91   #ifdef  IARGS
92 <        if (fa->niargs)
93 <                free((char *)fa->iarg);
92 >        if (fa->niargs) {
93 >                free((void *)fa->iarg);
94 >                fa->iarg = NULL;
95 >                fa->niargs = 0;
96 >        }
97   #endif
98 <        if (fa->nfargs)
99 <                free((char *)fa->farg);
98 >        if (fa->nfargs) {
99 >                free((void *)fa->farg);
100 >                fa->farg = NULL;
101 >                fa->nfargs = 0;
102 >        }
103   }
104 #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines