aboutsummaryrefslogtreecommitdiffstats
path: root/android/skin/window.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2009-10-06 17:27:59 -0700
committerDavid 'Digit' Turner <digit@google.com>2009-10-06 17:29:16 -0700
commit48ed3267dfffedb65385b0a1f1462fdd46d049bb (patch)
treec599ef453cffe405779aaf3fff66016e807b3569 /android/skin/window.c
parentbcc6ae14820ddb24e2403d84b420ce61f371ae94 (diff)
downloadexternal_qemu-48ed3267dfffedb65385b0a1f1462fdd46d049bb.zip
external_qemu-48ed3267dfffedb65385b0a1f1462fdd46d049bb.tar.gz
external_qemu-48ed3267dfffedb65385b0a1f1462fdd46d049bb.tar.bz2
Do not use qemu_malloc() to allocate arrays.
This function will call abort() for zero-sized arrays. This is stupid so use the Android-specific functions that return NULL instead.
Diffstat (limited to 'android/skin/window.c')
-rw-r--r--android/skin/window.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/android/skin/window.c b/android/skin/window.c
index 156ac56..24baaa6 100644
--- a/android/skin/window.c
+++ b/android/skin/window.c
@@ -14,6 +14,7 @@
#include "android/skin/scaler.h"
#include "android/charmap.h"
#include "android/utils/debug.h"
+#include "android/utils/system.h"
#include "android/hw-sensors.h"
#include <SDL_syswm.h>
#include "qemu-common.h"
@@ -767,9 +768,9 @@ layout_init( Layout* layout, SkinLayout* slayout )
layout->num_displays = n_displays;
/* now allocate arrays, then populate them */
- layout->buttons = qemu_mallocz( sizeof(Button) * n_buttons );
- layout->backgrounds = qemu_mallocz( sizeof(Background) * n_backgrounds );
- layout->displays = qemu_mallocz( sizeof(ADisplay) * n_displays );
+ AARRAY_NEW0(layout->buttons, n_buttons);
+ AARRAY_NEW0(layout->backgrounds, n_backgrounds);
+ AARRAY_NEW0(layout->displays, n_displays);
if (layout->buttons == NULL && n_buttons > 0) goto Fail;
if (layout->backgrounds == NULL && n_backgrounds > 0) goto Fail;
@@ -1021,7 +1022,9 @@ static int skin_window_reset_internal (SkinWindow*, SkinLayout*);
SkinWindow*
skin_window_create( SkinLayout* slayout, int x, int y, double scale, int no_display )
{
- SkinWindow* window = qemu_mallocz(sizeof(*window));
+ SkinWindow* window;
+
+ ANEW0(window);
window->shrink_scale = scale;
window->shrink = (scale != 1.0);
@@ -1173,7 +1176,7 @@ skin_window_resize( SkinWindow* window )
window_h = (int) ceil(window_h / scale );
window->shrink_surface = surface;
- window->shrink_pixels = qemu_mallocz( window_w * window_h * 4 );
+ AARRAY_NEW0(window->shrink_pixels, window_w * window_h * 4);
if (window->shrink_pixels == NULL) {
fprintf(stderr, "### Error: could not allocate memory for rescaling surface\n");
exit(1);