1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 int
 saf_setProps_Registry(SAF_LibProps *properties,            /* Library properties (See Properties) */
                       const char *name                    /* Name of object registry file */
                       )
 {
     SAF_ENTER_NOINIT(saf_setProps_Registry, SAF_PRECONDITION_ERROR);

     SAF_LibProps *p = properties;
     size_t i;

     SAF_REQUIRE(p, SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
                 _saf_errmsg("PROPERTIES must be a valid library properties handle"));
     SAF_REQUIRE(name && *name, SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
                 _saf_errmsg("NAME is required to be non-empty"));

     /* An easy-to-fool check that we're not adding the same thing more than once */
     for (i=0; i<p->reg.nused; i++) {
         if (!strcmp(name, p->reg.name[i]))
             SAF_RETURN(0);
     }

     /* Allocate more space for table */
     if (p->reg.nused>=p->reg.nalloc) {
         p->reg.nalloc = MAX(16, 2*p->reg.nalloc);
         p->reg.name = realloc(p->reg.name, p->reg.nalloc*sizeof(char*));
         p->reg.nowarn = realloc(p->reg.nowarn, p->reg.nalloc*sizeof(p->reg.nowarn[0]));
     }

     /* Add the name to the end of the list */
     p->reg.name[p->reg.nused] = _saf_strdup(name);
     p->reg.nowarn[p->reg.nused] = SAF_TRISTATE_FALSE;
     p->reg.nused++;

     SAF_LEAVE(0);
 }