mojoshader_common.c
changeset 1141 77468a2a9165
parent 1140 fad7ed946c06
child 1146 31337471b909
equal deleted inserted replaced
1140:fad7ed946c06 1141:77468a2a9165
   364     // no match!
   364     // no match!
   365     if (!addmissing)
   365     if (!addmissing)
   366         return NULL;
   366         return NULL;
   367 
   367 
   368     // add to the table.
   368     // add to the table.
   369     bucket = (StringBucket *) cache->m(sizeof (StringBucket), cache->d);
   369     bucket = (StringBucket *) cache->m(sizeof (StringBucket) + len + 1, cache->d);
   370     if (bucket == NULL)
   370     if (bucket == NULL)
   371         return NULL;
   371         return NULL;
   372     bucket->string = (char *) cache->m(len + 1, cache->d);
   372     bucket->string = (char *)(bucket + 1);
   373     if (bucket->string == NULL)
       
   374     {
       
   375         cache->f(bucket, cache->d);
       
   376         return NULL;
       
   377     } // if
       
   378     memcpy(bucket->string, str, len);
   373     memcpy(bucket->string, str, len);
   379     bucket->string[len] = '\0';
   374     bucket->string[len] = '\0';
   380     bucket->next = cache->hashtable[hash];
   375     bucket->next = cache->hashtable[hash];
   381     cache->hashtable[hash] = bucket;
   376     cache->hashtable[hash] = bucket;
   382     return bucket->string;
   377     return bucket->string;
   460         StringBucket *bucket = cache->hashtable[i];
   455         StringBucket *bucket = cache->hashtable[i];
   461         cache->hashtable[i] = NULL;
   456         cache->hashtable[i] = NULL;
   462         while (bucket)
   457         while (bucket)
   463         {
   458         {
   464             StringBucket *next = bucket->next;
   459             StringBucket *next = bucket->next;
   465             f(bucket->string, d);
       
   466             f(bucket, d);
   460             f(bucket, d);
   467             bucket = next;
   461             bucket = next;
   468         } // while
   462         } // while
   469     } // for
   463     } // for
   470 
   464