Bug 680840 - Use infallible allocations in GrowAtomTable() - r=dveditz, a=clegnitto
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 09 Sep 2011 18:00:21 -0400
changeset 73154 c792a27dae068129a09fc965f3ab2bc3c3d0591d
parent 73153 6464f5277ba619c1527b118560cce3099cc49c3d
child 73157 1a894427bc940ea57d88679aadecfcdbd02345ff
push id223
push userbjacob@mozilla.com
push dateWed, 14 Sep 2011 08:37:53 +0000
treeherdermozilla-beta@c792a27dae06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz, clegnitto
bugs680840
milestone7.0
Bug 680840 - Use infallible allocations in GrowAtomTable() - r=dveditz, a=clegnitto
gfx/angle/Makefile.in
gfx/angle/README.mozilla
gfx/angle/src/compiler/preprocessor/atom.c
gfx/angle/src/libEGL/Makefile.in
gfx/angle/src/libGLESv2/Makefile.in
--- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in
@@ -118,16 +118,18 @@ CSRCS   = \
         memory.c \
         scanner.c \
         symbols.c \
         tokens.c \
 	$(NULL)
 
 DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD
 
+EXTRA_DSO_LDOPTS = $(MOZALLOC_LIB)
+
 # ANGLE only on Win32 for now, the solution isn't set up
 # for 64-bit yet. This is handled by MOZ_ANGLE which the configure script
 # leaves undefined in the 64-bit case.
 ifdef MOZ_ANGLE
 
 # libEGL depends on (links against!) libGLESv2!
 DIRS = src/libGLESv2 src/libEGL
 
--- a/gfx/angle/README.mozilla
+++ b/gfx/angle/README.mozilla
@@ -7,16 +7,17 @@ Current revision: r653
 In this order:
   angle-nspr-misc.patch - don't bother with ANGLE_OS detection with NSPR
   angle-renaming.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles
   angle-intrinsic-msvc2005.patch - work around a MSVC 2005 compile error
   angle-amap-arev-fix.patch - plain bug fix, this is ANGLE r699
   angle-r702.patch - this is ANGLE r702
   angle-limit-identifiers-to-250-chars.patch - see bug 675625
   angle-r712.patch - this is ANGLE r712
+  angle-use-xmalloc.patch - see bug 680840. Can drop this patch whenever the new preprocessor lands.
 
 In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE.
 
 == How to update this ANGLE copy ==
 
 1. Unapply patches
 2. Apply diff with new ANGLE version
 3. Reapply patches.
--- a/gfx/angle/src/compiler/preprocessor/atom.c
+++ b/gfx/angle/src/compiler/preprocessor/atom.c
@@ -48,16 +48,18 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILI
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "compiler/compilerdebug.h"
 #include "compiler/preprocessor/slglobals.h"
 
+#include "../../../../../memory/mozalloc/mozalloc.h"
+
 #undef malloc
 #undef realloc
 #undef free
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////// String table: //////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -318,31 +320,23 @@ static int AddAtomFixed(AtomTable *atabl
  */
 
 static int GrowAtomTable(AtomTable *atable, int size)
 {
     int *newmap, *newrev;
 
     if (atable->size < size) {
         if (atable->amap) {
-            newmap = realloc(atable->amap, sizeof(int)*size);
-            newrev = realloc(atable->arev, sizeof(int)*size);
+            newmap = moz_xrealloc(atable->amap, sizeof(int)*size);
+            newrev = moz_xrealloc(atable->arev, sizeof(int)*size);
         } else {
-            newmap = malloc(sizeof(int)*size);
-            newrev = malloc(sizeof(int)*size);
+            newmap = moz_xmalloc(sizeof(int)*size);
+            newrev = moz_xmalloc(sizeof(int)*size);
             atable->size = 0;
         }
-        if (!newmap || !newrev) {
-            /* failed to grow -- error */
-            if (newmap)
-                atable->amap = newmap;
-            if (newrev)
-                atable->arev = newrev;
-            return -1;
-        }
         memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int));
         memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int));
         atable->amap = newmap;
         atable->arev = newrev;
         atable->size = size;
     }
     return 0;
 } // GrowAtomTable
--- a/gfx/angle/src/libEGL/Makefile.in
+++ b/gfx/angle/src/libEGL/Makefile.in
@@ -140,8 +140,10 @@ DEFFILE = $(srcdir)/libEGL.def
 include $(topsrcdir)/config/rules.mk
 
 EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3d9.lib" \
                    "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/dxguid.lib" \
 		   "$(DIST)/lib/libGLESv2.lib" \
 		   dwmapi.lib \
 		   delayimp.lib \
 		   /delayload:dwmapi.dll
+
+EXTRA_DSO_LDOPTS += $(MOZALLOC_LIB)
--- a/gfx/angle/src/libGLESv2/Makefile.in
+++ b/gfx/angle/src/libGLESv2/Makefile.in
@@ -149,8 +149,10 @@ CPPSRCS	+= \
 DEFFILE = $(srcdir)/libGLESv2.def
 
 
 include $(topsrcdir)/config/rules.mk
 
 EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3d9.lib" \
                    "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3dx9.lib" \
 		   "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/D3DCompiler.lib"
+
+EXTRA_DSO_LDOPTS += $(MOZALLOC_LIB)