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 <stdio.h> |
8 |
> |
#include "copyright.h" |
9 |
|
|
10 |
< |
#include <math.h> |
10 |
> |
#include "standard.h" |
11 |
|
|
15 |
– |
#include "fvect.h" |
16 |
– |
|
12 |
|
#include "object.h" |
13 |
|
|
14 |
|
|
20 |
– |
#ifndef MEMHOG |
21 |
– |
#define bmalloc malloc |
22 |
– |
#endif |
15 |
|
|
16 |
< |
extern char *bmalloc(), *savestr(), *fgetword(); |
17 |
< |
extern int atoi(); |
18 |
< |
extern long atol(); |
19 |
< |
|
20 |
< |
|
29 |
< |
readfargs(fa, fp) /* read function arguments from stream */ |
30 |
< |
register FUNARGS *fa; |
31 |
< |
FILE *fp; |
16 |
> |
int |
17 |
> |
readfargs( /* read function arguments from stream */ |
18 |
> |
FUNARGS *fa, |
19 |
> |
FILE *fp |
20 |
> |
) |
21 |
|
{ |
22 |
|
#define getstr(s) (fgetword(s,sizeof(s),fp)!=NULL) |
23 |
|
#define getint(s) (getstr(s) && isint(s)) |
24 |
|
#define getflt(s) (getstr(s) && isflt(s)) |
25 |
|
char sbuf[MAXSTR]; |
26 |
< |
register int n, i; |
26 |
> |
int n, i; |
27 |
|
|
28 |
|
if (!getint(sbuf) || (n = atoi(sbuf)) < 0) |
29 |
|
return(0); |
30 |
< |
if (fa->nsargs = n) { |
31 |
< |
fa->sarg = (char **)bmalloc(n*sizeof(char *)); |
30 |
> |
if ( (fa->nsargs = n) ) { |
31 |
> |
fa->sarg = (char **)malloc(n*sizeof(char *)); |
32 |
|
if (fa->sarg == NULL) |
33 |
|
return(-1); |
34 |
|
for (i = 0; i < fa->nsargs; i++) { |
42 |
|
return(0); |
43 |
|
#ifdef IARGS |
44 |
|
if (fa->niargs = n) { |
45 |
< |
fa->iarg = (long *)bmalloc(n*sizeof(long)); |
45 |
> |
fa->iarg = (long *)malloc(n*sizeof(long)); |
46 |
|
if (fa->iarg == NULL) |
47 |
|
return(-1); |
48 |
|
for (i = 0; i < n; i++) { |
58 |
|
#endif |
59 |
|
if (!getint(sbuf) || (n = atoi(sbuf)) < 0) |
60 |
|
return(0); |
61 |
< |
if (fa->nfargs = n) { |
62 |
< |
fa->farg = (FLOAT *)bmalloc(n*sizeof(FLOAT)); |
61 |
> |
if ( (fa->nfargs = n) ) { |
62 |
> |
fa->farg = (RREAL *)malloc(n*sizeof(RREAL)); |
63 |
|
if (fa->farg == NULL) |
64 |
|
return(-1); |
65 |
|
for (i = 0; i < n; i++) { |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
< |
#ifndef MEMHOG |
80 |
< |
freefargs(fa) /* free object arguments */ |
81 |
< |
register FUNARGS *fa; |
79 |
> |
void |
80 |
> |
freefargs( /* free object arguments */ |
81 |
> |
FUNARGS *fa |
82 |
> |
) |
83 |
|
{ |
84 |
< |
register int i; |
84 |
> |
int i; |
85 |
|
|
86 |
|
if (fa->nsargs) { |
87 |
|
for (i = 0; i < fa->nsargs; i++) |
88 |
|
freestr(fa->sarg[i]); |
89 |
< |
free((char *)fa->sarg); |
89 |
> |
free((void *)fa->sarg); |
90 |
> |
fa->sarg = NULL; |
91 |
> |
fa->nsargs = 0; |
92 |
|
} |
93 |
|
#ifdef IARGS |
94 |
< |
if (fa->niargs) |
95 |
< |
free((char *)fa->iarg); |
94 |
> |
if (fa->niargs) { |
95 |
> |
free((void *)fa->iarg); |
96 |
> |
fa->iarg = NULL; |
97 |
> |
fa->niargs = 0; |
98 |
> |
} |
99 |
|
#endif |
100 |
< |
if (fa->nfargs) |
101 |
< |
free((char *)fa->farg); |
100 |
> |
if (fa->nfargs) { |
101 |
> |
free((void *)fa->farg); |
102 |
> |
fa->farg = NULL; |
103 |
> |
fa->nfargs = 0; |
104 |
> |
} |
105 |
|
} |
108 |
– |
#endif |