dmx: Fix calloc macro confusion.

This commit is contained in:
Adam Jackson 2008-12-19 09:51:52 -05:00
parent 8c488ac3b3
commit 5a072c5535
4 changed files with 18 additions and 14 deletions

View File

@ -341,21 +341,21 @@ do { \
#define _MAXSCREENSALLOCF(o,size,fatal) \ #define _MAXSCREENSALLOCF(o,size,fatal) \
do { \ do { \
if (!o) { \ if (!o) { \
o = xcalloc((size), sizeof(*(o))); \ o = calloc((size), sizeof(*(o))); \
if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \ if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
} \ } \
} while (0) } while (0)
#define _MAXSCREENSALLOCR(o,size,retval) \ #define _MAXSCREENSALLOCR(o,size,retval) \
do { \ do { \
if (!o) { \ if (!o) { \
o = xcalloc((size), sizeof(*(o))); \ o = calloc((size), sizeof(*(o))); \
if (!o) return retval; \ if (!o) return retval; \
} \ } \
} while (0) } while (0)
#define MAXSCREENSFREE(o) \ #define MAXSCREENSFREE(o) \
do { \ do { \
if (o) xfree(o); \ if (o) free(o); \
o = NULL; \ o = NULL; \
} while (0) } while (0)

View File

@ -41,6 +41,8 @@
#include <dmx-config.h> #include <dmx-config.h>
#endif #endif
#include <stdlib.h>
#include "dmx.h" #include "dmx.h"
#include "dmxinit.h" #include "dmxinit.h"
#include "dmxextension.h" #include "dmxextension.h"
@ -1121,9 +1123,9 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
} }
/* Now allocate the memory we need */ /* Now allocate the memory we need */
images = xcalloc(len_images, sizeof(char)); images = calloc(len_images, sizeof(char));
gids = xalloc(glyphSet->hash.tableEntries*sizeof(Glyph)); gids = malloc(glyphSet->hash.tableEntries*sizeof(Glyph));
glyphs = xalloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo)); glyphs = malloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
pos = images; pos = images;
ctr = 0; ctr = 0;
@ -1158,9 +1160,9 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
len_images); len_images);
/* Clean up */ /* Clean up */
xfree(len_images); free(len_images);
xfree(gids); free(gids);
xfree(glyphs); free(glyphs);
} }
#endif #endif

View File

@ -34,6 +34,7 @@
#include <pixmapstr.h> #include <pixmapstr.h>
#include <windowstr.h> #include <windowstr.h>
#include "glxutil.h" #include "glxutil.h"
#include <stdlib.h>
/************************************************************************/ /************************************************************************/
@ -51,7 +52,7 @@ __glXMalloc(size_t size)
if (size == 0) { if (size == 0) {
return NULL; return NULL;
} }
addr = (void *) xalloc(size); addr = malloc(size);
if (addr == NULL) { if (addr == NULL) {
/* XXX: handle out of memory error */ /* XXX: handle out of memory error */
return NULL; return NULL;
@ -68,7 +69,7 @@ __glXCalloc(size_t numElements, size_t elementSize)
if ((numElements == 0) || (elementSize == 0)) { if ((numElements == 0) || (elementSize == 0)) {
return NULL; return NULL;
} }
addr = xcalloc(numElements, elementSize); addr = calloc(numElements, elementSize);
if (addr == NULL) { if (addr == NULL) {
/* XXX: handle out of memory error */ /* XXX: handle out of memory error */
return NULL; return NULL;
@ -86,13 +87,13 @@ __glXRealloc(void *addr, size_t newSize)
xfree(addr); xfree(addr);
return NULL; return NULL;
} else { } else {
newAddr = xrealloc(addr, newSize); newAddr = realloc(addr, newSize);
} }
} else { } else {
if (newSize == 0) { if (newSize == 0) {
return NULL; return NULL;
} else { } else {
newAddr = xalloc(newSize); newAddr = malloc(newSize);
} }
} }
if (newAddr == NULL) { if (newAddr == NULL) {
@ -106,6 +107,6 @@ void
__glXFree(void *addr) __glXFree(void *addr)
{ {
if (addr) { if (addr) {
xfree(addr); free(addr);
} }
} }

View File

@ -37,6 +37,7 @@
#include "glxserver.h" #include "glxserver.h"
#include "glxutil.h" #include "glxutil.h"
#include "dmx_glxvisuals.h" #include "dmx_glxvisuals.h"
#include <stdlib.h>
static int numConfigs = 0; static int numConfigs = 0;
static __GLXvisualConfig *visualConfigs = NULL; static __GLXvisualConfig *visualConfigs = NULL;