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

Comparing ray/src/common/instance.c (file contents):
Revision 2.13 by greg, Tue Nov 5 00:03:10 2024 UTC vs.
Revision 2.14 by greg, Thu Dec 12 20:04:46 2024 UTC

# Line 34 | Line 34 | getscene(                              /* get new octree reference */
34          for (sc = slist; sc != NULL; sc = sc->next)
35                  if (!strcmp(sname, sc->name))
36                          break;
37 <        if (sc == NULL) {
38 <                sc = (SCENE *)malloc(sizeof(SCENE));
37 >        if (sc == NULL) {               /* new instance? */
38 >                sc = (SCENE *)calloc(1, sizeof(SCENE));
39                  if (sc == NULL)
40                          error(SYSTEM, "out of memory in getscene");
41                  sc->name = savestr(sname);
42                sc->nref = 0;
43                sc->ldflags = 0;
42                  sc->scube.cutree = EMPTY;
45                sc->scube.cuorg[0] = sc->scube.cuorg[1] =
46                                sc->scube.cuorg[2] = 0.;
47                sc->scube.cusize = 0.;
48                sc->firstobj = sc->nobjs = 0;
43                  sc->next = slist;
44                  slist = sc;
45          }
46 +        sc->nref++;                     /* bump reference count */
47 +        if (!(flags &= ~sc->ldflags))   /* nothing to load? */
48 +                return(sc);
49          if ((pathname = getpath(sname, getrlibpath(), R_OK)) == NULL) {
50                  sprintf(errmsg, "cannot find octree file \"%s\"", sname);
51                  error(SYSTEM, errmsg);
52          }
56        flags &= ~sc->ldflags;          /* skip what's already loaded */
53          if (flags & IO_SCENE)
54                  sc->firstobj = nobjects;
55          if (flags)
# Line 61 | Line 57 | getscene(                              /* get new octree reference */
57          if (flags & IO_SCENE)
58                  sc->nobjs = nobjects - sc->firstobj;
59          sc->ldflags |= flags;
64        sc->nref++;                     /* increase reference count */
60          return(sc);
61   }
62  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines