[cairo] Using OS/2 memory allocation APIs

Peter Weilbacher mozilla at weilbacher.org
Mon Nov 19 16:38:33 PST 2007


This is something I have tried for Mozilla apps on OS/2. When I use the
OS/2 APIs to allocate some of the larger buffers for cairo, these are
given back to the system immediately when freeing them. This apparently
reduces memory fragmentation a lot compared to using standard C functions,
so I would really like to get this in.

The attached patch leaves the standard functions in place (as the default
option on compilation) because using DosAllocMem() is not desirable for
all programs (it has some extra memory overhead that would be noticeable
for smaller programs).

I thought of replacing the Vlad's _cairo_malloc macros with something like
this for OS/2, so that other parts of the code could also benefit from
this. But I think I would actually convert the macros to functions then
because this API returns the allocated memory pointer in an argument
instead of the return value. So in principle I'm asking, if the attached
patch would be good to push (sorry, it's against the Mozilla CVS version,
can't access git right now). I was also thinking about adding similar
#ifdefs in cairo-pdf-surface.c, cairo-image-surface.c , and pixman-image.c
for the pixel buffers that are allocated and freed there...

    Peter.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-list_DosAllocMem.diff
Type: application/x-diff
Size: 11945 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071120/6adf14f6/attachment-0001.bin 


More information about the cairo mailing list