Back to index

radiance  4R0+20100331
Defines | Functions | Variables
object.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "parser.h"

Go to the source code of this file.

Defines

#define ALLOC_INC   16 /* list increment ( > 1 ) */

Functions

int obj_handler (int ac, char **av)
void obj_clear ()

Variables

static const char RCSid [] = "$Id: object.c,v 1.6 2003/02/28 20:11:29 greg Exp $"
int obj_nnames
char ** obj_name
static int obj_maxname

Define Documentation

#define ALLOC_INC   16 /* list increment ( > 1 ) */

Definition at line 19 of file object.c.


Function Documentation

void obj_clear ( void  )

Definition at line 59 of file object.c.

{
       while (obj_nnames)
              free((MEM_PTR)obj_name[--obj_nnames]);
       if (obj_maxname) {
              free((MEM_PTR)obj_name);
              obj_maxname = 0;
       }
}
int obj_handler ( int  ac,
char **  av 
)

Definition at line 23 of file object.c.

{
       if (ac == 1) {                            /* just pop top object */
              if (obj_nnames < 1)
                     return(MG_ECNTXT);
              free((MEM_PTR)obj_name[--obj_nnames]);
              obj_name[obj_nnames] = NULL;
              return(MG_OK);
       }
       if (ac != 2)
              return(MG_EARGC);
       if (!isname(av[1]))
              return(MG_EILL);
       if (obj_nnames >= obj_maxname-1) { /* enlarge array */
              if (!obj_maxname)
                     obj_name = (char **)malloc(
                            (obj_maxname=ALLOC_INC)*sizeof(char *));
              else
                     obj_name = (char **)realloc((MEM_PTR)obj_name,
                            (obj_maxname+=ALLOC_INC)*sizeof(char *));
              if (obj_name == NULL)
                     return(MG_EMEM);
       }
                                          /* allocate new entry */
       obj_name[obj_nnames] = (char *)malloc(strlen(av[1])+1);
       if (obj_name[obj_nnames] == NULL)
              return(MG_EMEM);
       strcpy(obj_name[obj_nnames++], av[1]);
       obj_name[obj_nnames] = NULL;
       return(MG_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int obj_maxname [static]

Definition at line 17 of file object.c.

char** obj_name

Definition at line 15 of file object.c.

Definition at line 14 of file object.c.

const char RCSid[] = "$Id: object.c,v 1.6 2003/02/28 20:11:29 greg Exp $" [static]

Definition at line 2 of file object.c.