[Mesa-dev] [PATCH 4/6] util: in _mesa_set_create() mark error if out of memory

Kenneth Graunke kenneth at whitecape.org
Mon Jan 26 01:19:37 PST 2015


On Monday, January 26, 2015 11:07:49 AM Juha-Pekka Heikkila wrote:
> added calls to _mesa_error_no_memory() if memory allocation
> returned null pointer.
> 
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
>  src/util/set.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/set.c b/src/util/set.c
> index c3252a0..b0baccc 100644
> --- a/src/util/set.c
> +++ b/src/util/set.c
> @@ -38,6 +38,7 @@
>  #include "macros.h"
>  #include "ralloc.h"
>  #include "set.h"
> +#include "main/errors.h"
>  
>  /*
>   * From Knuth -- a good choice for hash/rehash values is p, p-2 where
> @@ -111,8 +112,10 @@ _mesa_set_create(void *mem_ctx,
>     struct set *ht;
>  
>     ht = ralloc(mem_ctx, struct set);
> -   if (ht == NULL)
> +   if (ht == NULL) {
> +      _mesa_error_no_memory(__func__);
>        return NULL;
> +   }
>  
>     ht->size_index = 0;
>     ht->size = hash_sizes[ht->size_index].size;
> @@ -125,6 +128,7 @@ _mesa_set_create(void *mem_ctx,
>     ht->deleted_entries = 0;
>  
>     if (ht->table == NULL) {
> +      _mesa_error_no_memory(__func__);
>        ralloc_free(ht);
>        return NULL;
>     }
> 

No...just no.  This is a generic data structure implementation.
Hash table and set implementations should not be using OpenGL contexts.
They shouldn't even think about OpenGL contexts.
No good can come of this.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150126/9af0a5b7/attachment.sig>


More information about the mesa-dev mailing list