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

Comparing ray/src/cv/mgflib/object.c (file contents):
Revision 1.1 by greg, Tue Jun 21 14:45:46 1994 UTC vs.
Revision 1.6 by greg, Fri Feb 28 20:11:29 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 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   * Header file for tracking hierarchical object names
6   */
7  
8   #include <stdio.h>
9 + #include <stdlib.h>
10   #include <string.h>
11   #include "parser.h"
12  
# Line 18 | Line 16 | char   **obj_name;                     /* name list */
16  
17   static int      obj_maxname;            /* allocated list size */
18  
19 < #define ALLOC_INC       16              /* list increment */
19 > #define ALLOC_INC       16              /* list increment ( > 1 ) */
20  
21  
22   int
# Line 28 | Line 26 | char   **av;
26   {
27          if (ac == 1) {                          /* just pop top object */
28                  if (obj_nnames < 1)
29 <                        return(MG_OK);          /* should be error? */
29 >                        return(MG_ECNTXT);
30                  free((MEM_PTR)obj_name[--obj_nnames]);
31                  obj_name[obj_nnames] = NULL;
32                  return(MG_OK);
33          }
34          if (ac != 2)
35                  return(MG_EARGC);
36 <        if (obj_nnames >= obj_maxname) {        /* enlarge array */
36 >        if (!isname(av[1]))
37 >                return(MG_EILL);
38 >        if (obj_nnames >= obj_maxname-1) {      /* enlarge array */
39                  if (!obj_maxname)
40                          obj_name = (char **)malloc(
41                                  (obj_maxname=ALLOC_INC)*sizeof(char *));
# Line 52 | Line 52 | char   **av;
52          strcpy(obj_name[obj_nnames++], av[1]);
53          obj_name[obj_nnames] = NULL;
54          return(MG_OK);
55 + }
56 +
57 +
58 + void
59 + obj_clear()                     /* clear object stack */
60 + {
61 +        while (obj_nnames)
62 +                free((MEM_PTR)obj_name[--obj_nnames]);
63 +        if (obj_maxname) {
64 +                free((MEM_PTR)obj_name);
65 +                obj_maxname = 0;
66 +        }
67   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines