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) \
do { \
if (!o) { \
o = xcalloc((size), sizeof(*(o))); \
o = calloc((size), sizeof(*(o))); \
if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
} \
} while (0)
#define _MAXSCREENSALLOCR(o,size,retval) \
do { \
if (!o) { \
o = xcalloc((size), sizeof(*(o))); \
o = calloc((size), sizeof(*(o))); \
if (!o) return retval; \
} \
} while (0)
#define MAXSCREENSFREE(o) \
do { \
if (o) xfree(o); \
if (o) free(o); \
o = NULL; \
} while (0)

View File

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

View File

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

View File

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