What is XMALLOC and how it compares with malloc?

David Daney ddaney at avtrex.com
Thu May 3 12:48:10 PDT 2007


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