diff options
author | Zack Rusin <zack@tungstengraphics.com> | 2008-04-21 16:04:27 -0400 |
---|---|---|
committer | Zack Rusin <zack@tungstengraphics.com> | 2008-04-21 16:10:55 -0400 |
commit | 0879237725eca893318137b795d4234300a37e9a (patch) | |
tree | da61601f104cebfc9ac0d994201ebe8d63638c0d /src/gallium/auxiliary/cso_cache/cso_hash.c | |
parent | 9fe63929011cd9c4d86ab6525555a3e53423c854 (diff) |
handle some of the possible allocation failures within the hash itself
Diffstat (limited to 'src/gallium/auxiliary/cso_cache/cso_hash.c')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_hash.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.c b/src/gallium/auxiliary/cso_cache/cso_hash.c index ddce3822f7..8d867f86d2 100644 --- a/src/gallium/auxiliary/cso_cache/cso_hash.c +++ b/src/gallium/auxiliary/cso_cache/cso_hash.c @@ -110,6 +110,10 @@ cso_hash_create_node(struct cso_hash *hash, struct cso_node **anextNode) { struct cso_node *node = cso_data_allocate_node(hash->data.d); + + if (!node) + return NULL; + node->key = akey; node->value = avalue; @@ -219,6 +223,11 @@ struct cso_hash_iter cso_hash_insert(struct cso_hash *hash, { struct cso_node **nextNode = cso_hash_find_node(hash, key); struct cso_node *node = cso_hash_create_node(hash, key, data, nextNode); + if (!node) { + struct cso_hash_iter null_iter = {hash, 0}; + return null_iter; + } + struct cso_hash_iter iter = {hash, node}; return iter; } @@ -227,7 +236,15 @@ struct cso_hash_iter cso_hash_insert(struct cso_hash *hash, struct cso_hash * cso_hash_create(void) { struct cso_hash *hash = MALLOC_STRUCT(cso_hash); + if (!hash) + return NULL; + hash->data.d = MALLOC_STRUCT(cso_hash_data); + if (!hash->data.d) { + FREE(hash); + return NULL; + } + hash->data.d->fakeNext = 0; hash->data.d->buckets = 0; hash->data.d->size = 0; |