What is XMALLOC and how it compares with malloc?

Edward Huang ehuang at ix.netcom.com
Sun May 6 18:25:12 UTC 2007


Dear David, Mike, Kevin, etc

Thank you all for quick responses.  Mike and David were right, it is a
wrapper in rdesktop.c, thanks for pointing it out.  Some of the code used
Malloc, some used Xmalloc.   So I've made it consistently use xmalloc as it
has error checking

Stil getting segmentation fault, trace show it occurs upon calling malloc

Could this mean something is corrupting the heap / malloc's housekeeping
such that malloc panics?

 

-----Original Message-----
From: David Daney [mailto:ddaney at avtrex.com] 
Sent: Thursday, May 03, 2007 12:48 PM
To: ehuang at ix.netcom.com
Cc: Mike Frysinger; uclibc at uclibc.org
Subject: Re: What is XMALLOC and how it compares with malloc?

ehuang at ix.netcom.com wrote:
> Dear Mike,
> 
> thanks for quickly getting back to me.  
> 
> The application is RDESKTOP.  It has mess of both malloc and xmalloc.
> Runs fine on Fedora Core (presumely glibc) but get segfaults under Cirrus
ARM
> linux which uses libcClibc-0.9.28.so    So, I'm trying to understand and
> trace the memory management.  Whats frustrating is not finding any 
> decent explanation thru google about XMALLOC.  Not even wikipedia!
> 

Wow, not even in wikipedia?!  Have you tried looking at the source code of
the function?

According to your grep, you should be able to find it in rdesktop.c.

David Daney

> 
> GREP MALLOC
> 
> cache.c:                text->data = xmalloc(length);
> nwin.c: uint8 *d2 = xmalloc(width * height);
> nwin.c: uint8 *d2 = xmalloc(width * height * (depth / 8));
> nwin.c: bmp = (GR_IMAGE_HDR*)malloc(sizeof(GR_IMAGE_HDR));
> nwin.c: bmp->palette = (MWPALENTRY*)malloc(2 * sizeof(MWPALENTRY));
> nwin.c: bmp->imagebits = (MWUCHAR*)malloc(datasize); 
> nwin.c:STATUS("doing malloc - sizeof %d\n",sizeof(GR_PALETTE) );
> nwin.c:    pal = (GR_PALETTE*)malloc(sizeof(GR_PALETTE)); 
> nwin.c:    STATUS("malloc error!\n");
> nwin.c: pixels = (GR_PIXELVAL*)malloc(cx * cy * depth);
> orders.c:       d2 = xmalloc(width*height);
> orders.c:       bmpdata = xmalloc(width * height);
> orders.c:       map.colours = xmalloc(3 * map.ncolours);
> orders.c:               rev_data = xmalloc(datasize);
> rdesktop.c:#include <stdlib.h>  /* malloc realloc free */
> rdesktop.c:                     char *errormsg = (char *)malloc(500);
> rdesktop.c:/* malloc; exit if out of memory */ rdesktop.c:void 
> *xmalloc2(int l, char *s, int size)
> rdesktop.c:     void *mem = malloc(size);
> rdesktop.c:             ERROR("xmalloc %d\n", size);
> rdesktop.c:/* malloc; exit if out of memory */ rdesktop.c:void 
> *xmalloc(int size)
> rdesktop.c:     void *mem = malloc(size);
> rdesktop.c:             ERROR("xmalloc %d\n", size);
> rdp.c:                  rawdata = xmalloc(width * height);
> rdp.c:                  rawdata = xmalloc(width * height);
> secure.c:       mcs_data.p = mcs_data.data = xmalloc(mcs_data.size);
> tcp.c:  in.data = xmalloc(in.size);
> tcp.c:  out.data = xmalloc(out.size);
>




More information about the uClibc mailing list