gallivm: Cope with tgsi instruction reallocation failure.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 2 Sep 2010 10:30:13 +0000 (11:30 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Sun, 5 Sep 2010 09:17:51 +0000 (10:17 +0100)
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c

index 0e07f7f3f38e2666cb57592c4be6539f0b37b863..871bec2a41160d957ea0f9d382085dd36d19b0cc 100644 (file)
@@ -612,7 +612,6 @@ emit_fetch(
       break;
 
    case TGSI_UTIL_SIGN_SET:
-      /* TODO: Use bitwese OR for floating point */
       res = lp_build_abs( &bld->base, res );
       /* fall through */
    case TGSI_UTIL_SIGN_TOGGLE:
@@ -2063,11 +2062,16 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
          {
             /* save expanded instruction */
             if (num_instructions == bld.max_instructions) {
-               bld.instructions = REALLOC(bld.instructions,
-                                          bld.max_instructions
-                                          * sizeof(struct tgsi_full_instruction),
-                                          (bld.max_instructions + LP_MAX_INSTRUCTIONS)
-                                          * sizeof(struct tgsi_full_instruction));
+               struct tgsi_full_instruction *instructions;
+               instructions = REALLOC(bld.instructions,
+                                      bld.max_instructions
+                                      * sizeof(struct tgsi_full_instruction),
+                                      (bld.max_instructions + LP_MAX_INSTRUCTIONS)
+                                      * sizeof(struct tgsi_full_instruction));
+               if (!instructions) {
+                  break;
+               }
+               bld.instructions = instructions;
                bld.max_instructions += LP_MAX_INSTRUCTIONS;
             }