Bug 680840 - Use infallible allocations in GrowAtomTable() - r=dveditz

This commit is contained in:
Benoit Jacob 2011-09-09 18:00:21 -04:00
parent f90fd5539e
commit 7f79f5e7b1
5 changed files with 13 additions and 12 deletions

View File

@ -128,6 +128,8 @@ CSRCS = \
DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD
EXTRA_DSO_LDOPTS = $(MOZALLOC_LIB)
ifdef MOZ_ANGLE
# libEGL depends on (links against!) libGLESv2!

View File

@ -9,6 +9,7 @@ In this order:
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-limit-identifiers-to-250-chars.patch - see bug 675625
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.

View File

@ -53,6 +53,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "compiler/compilerdebug.h"
#include "compiler/preprocessor/slglobals.h"
#include "../../../../../memory/mozalloc/mozalloc.h"
#undef malloc
#undef realloc
#undef free
@ -323,21 +325,13 @@ static int GrowAtomTable(AtomTable *atable, int size)
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;

View File

@ -155,3 +155,5 @@ EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)/d3
dwmapi.lib \
delayimp.lib \
/delayload:dwmapi.dll
EXTRA_DSO_LDOPTS += $(MOZALLOC_LIB)

View File

@ -164,3 +164,5 @@ include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)/d3d9.lib" \
"$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)/d3dx9.lib" \
"$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)/D3DCompiler.lib"
EXTRA_DSO_LDOPTS += $(MOZALLOC_LIB)