mojoshader_common.c
changeset 735 78c882b8c813
parent 734 1f69fc50c79c
child 858 d51537335896
equal deleted inserted replaced
734:1f69fc50c79c 735:78c882b8c813
    64               const HashTable_NukeFn nukefn,
    64               const HashTable_NukeFn nukefn,
    65               const int stackable,
    65               const int stackable,
    66               MOJOSHADER_malloc m, MOJOSHADER_free f, void *d)
    66               MOJOSHADER_malloc m, MOJOSHADER_free f, void *d)
    67 {
    67 {
    68     const uint32 alloc_len = sizeof (HashItem *) * initial_table_size;
    68     const uint32 alloc_len = sizeof (HashItem *) * initial_table_size;
    69     HashTable *table = (HashTable *) m(sizeof (HashTable));
    69     HashTable *table = (HashTable *) m(sizeof (HashTable), d);
    70     if (table == NULL)
    70     if (table == NULL)
    71         return 0;
    71         return NULL;
    72     memset(table, '\0', sizeof (HashTable));
    72     memset(table, '\0', sizeof (HashTable));
    73 
    73 
    74     table->table = (HashItem **) m(alloc_len, d);
    74     table->table = (HashItem **) m(alloc_len, d);
    75     if (table->table == NULL)
    75     if (table->table == NULL)
    76     {
    76     {
    77         f(table, d);
    77         f(table, d);
    78         return 0;
    78         return NULL;
    79     } // if
    79     } // if
    80 
    80 
    81     memset(table->table, '\0', alloc_len);
    81     memset(table->table, '\0', alloc_len);
    82     table->table_len = initial_table_size;
    82     table->table_len = initial_table_size;
    83     table->stackable = stackable;
    83     table->stackable = stackable;
    85     table->keymatch = keymatchfn;
    85     table->keymatch = keymatchfn;
    86     table->nuke = nukefn;
    86     table->nuke = nukefn;
    87     table->malloc = m;
    87     table->malloc = m;
    88     table->free = f;
    88     table->free = f;
    89     table->malloc_data = d;
    89     table->malloc_data = d;
    90     return 1;
    90     return table;
    91 } // hash_create
    91 } // hash_create
    92 
    92 
    93 void hash_destroy(HashTable *table)
    93 void hash_destroy(HashTable *table)
    94 {
    94 {
    95     uint32 i;
    95     uint32 i;