diff --git a/src/Makefile.sources b/src/Makefile.sources
index 842aec2..01f2fca 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -63,7 +63,7 @@ cairo_private = \
 	cairo-freelist-private.h \
 	cairo-gstate-private.h \
 	cairo-hash-private.h \
-	cairo-malloc-private.h \
+	cairo-_cairo_malloc-private.h \
 	cairo-meta-surface-private.h \
 	cairo-mutex-impl-private.h \
 	cairo-mutex-list-private.h \
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 057be52..45d552f 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -774,7 +774,7 @@ _cairo_analysis_surface_create (cairo_surface_t		*target,
     if (status)
 	return _cairo_surface_create_in_error (status);
 
-    surface = malloc (sizeof (cairo_analysis_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_analysis_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -977,7 +977,7 @@ _cairo_null_surface_create (cairo_content_t content)
 {
     cairo_surface_t *surface;
 
-    surface = malloc (sizeof (cairo_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_surface_t));
     if (surface == NULL) {
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
     }
diff --git a/src/cairo-array.c b/src/cairo-array.c
index b2790c8..7b3dd41 100644
--- a/src/cairo-array.c
+++ b/src/cairo-array.c
@@ -137,7 +137,7 @@ _cairo_array_grow_by (cairo_array_t *array, unsigned int additional)
 	new_size = new_size * 2;
 
     if (array->elements == NULL) {
-	array->elements = malloc (sizeof (char *));
+	array->elements = _cairo_malloc (sizeof (char *));
 	if (array->elements == NULL)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
diff --git a/src/cairo-base85-stream.c b/src/cairo-base85-stream.c
index 8897403..fb9c769 100644
--- a/src/cairo-base85-stream.c
+++ b/src/cairo-base85-stream.c
@@ -116,7 +116,7 @@ _cairo_base85_stream_create (cairo_output_stream_t *output)
     if (output->status)
 	return _cairo_output_stream_create_in_error (output->status);
 
-    stream = malloc (sizeof (cairo_base85_stream_t));
+    stream = _cairo_malloc (sizeof (cairo_base85_stream_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-cache.c b/src/cairo-cache.c
index 1c458df..352bd7b 100644
--- a/src/cairo-cache.c
+++ b/src/cairo-cache.c
@@ -129,7 +129,7 @@ _cairo_cache_create (cairo_cache_keys_equal_func_t keys_equal,
     cairo_status_t status;
     cairo_cache_t *cache;
 
-    cache = malloc (sizeof (cairo_cache_t));
+    cache = _cairo_malloc (sizeof (cairo_cache_t));
     if (cache == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 008cc68..6a03152 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -398,7 +398,7 @@ cff_index_append_copy (cairo_array_t *index,
 
     element.length = length;
     element.is_copy = TRUE;
-    element.data = malloc (element.length);
+    element.data = _cairo_malloc (element.length);
     if (element.data == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -461,12 +461,12 @@ cff_dict_create_operator (int            operator,
 {
     cff_dict_operator_t *op;
 
-    op = malloc (sizeof (cff_dict_operator_t));
+    op = _cairo_malloc (sizeof (cff_dict_operator_t));
     if (op == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     _cairo_dict_init_key (op, operator);
-    op->operand = malloc (operand_length);
+    op->operand = _cairo_malloc (operand_length);
     if (op->operand == NULL) {
         free (op);
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -570,7 +570,7 @@ cff_dict_set_operands (cairo_hash_table_t *dict,
                                   (cairo_hash_entry_t **) &op))
     {
         free (op->operand);
-        op->operand = malloc (size);
+        op->operand = _cairo_malloc (size);
 	if (op->operand == NULL)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1173,7 +1173,7 @@ cairo_cff_font_create_cid_fontdict (cairo_cff_font_t *font)
     cairo_status_t status;
 
     font->num_fontdicts = 1;
-    font->fd_dict = malloc (sizeof (cairo_hash_table_t *));
+    font->fd_dict = _cairo_malloc (sizeof (cairo_hash_table_t *));
     if (font->fd_dict == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1184,11 +1184,11 @@ cairo_cff_font_create_cid_fontdict (cairo_cff_font_t *font)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
-    font->fd_subset_map = malloc (sizeof (int));
+    font->fd_subset_map = _cairo_malloc (sizeof (int));
     if (font->fd_subset_map == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    font->private_dict_offset = malloc (sizeof (int));
+    font->private_dict_offset = _cairo_malloc (sizeof (int));
     if (font->private_dict_offset == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1760,7 +1760,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     if (status)
         return status;
 
-    name = malloc (size);
+    name = _cairo_malloc (size);
     if (name == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1770,7 +1770,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     if (status)
         goto fail1;
 
-    font = malloc (sizeof (cairo_cff_font_t));
+    font = _cairo_malloc (sizeof (cairo_cff_font_t));
     if (font == NULL) {
         status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail1;
@@ -1808,7 +1808,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
         if ((be16_to_cpu (record->platform) == 1) &&
             (be16_to_cpu (record->encoding) == 0) &&
             (be16_to_cpu (record->name) == 4)) {
-            font->font_name = malloc (be16_to_cpu(record->length) + 1);
+            font->font_name = _cairo_malloc (be16_to_cpu(record->length) + 1);
             if (font->font_name) {
                 strncpy(font->font_name,
                         ((char*)name) + be16_to_cpu (name->strings_offset) + be16_to_cpu (record->offset),
@@ -1820,7 +1820,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     }
 
     if (font->font_name == NULL) {
-        font->font_name = malloc (30);
+        font->font_name = _cairo_malloc (30);
         if (font->font_name == NULL) {
             status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
             goto fail3;
@@ -1848,7 +1848,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
 	goto fail5;
 
     font->data_length = data_length;
-    font->data = malloc (data_length);
+    font->data = _cairo_malloc (data_length);
     if (font->data == NULL) {
         status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
         goto fail5;
@@ -2003,7 +2003,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t          *cff_subset,
     cff_subset->ascent = font->ascent;
     cff_subset->descent = font->descent;
 
-    cff_subset->data = malloc (length);
+    cff_subset->data = _cairo_malloc (length);
     if (cff_subset->data == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail3;
@@ -2042,7 +2042,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t  *scaled_font_subset
     cairo_status_t status;
     cairo_cff_font_t *font;
 
-    font = malloc (sizeof (cairo_cff_font_t));
+    font = _cairo_malloc (sizeof (cairo_cff_font_t));
     if (font == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -2251,7 +2251,7 @@ _cairo_cff_fallback_init (cairo_cff_subset_t          *cff_subset,
     cff_subset->ascent = type2_subset.y_max;
     cff_subset->descent = type2_subset.y_min;
 
-    cff_subset->data = malloc (length);
+    cff_subset->data = _cairo_malloc (length);
     if (cff_subset->data == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail4;
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index b00ca39..d854bfa 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -316,7 +316,7 @@ _cairo_clip_intersect_path (cairo_clip_t       *clip,
     if (clip->mode != CAIRO_CLIP_MODE_PATH)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    clip_path = malloc (sizeof (cairo_clip_path_t));
+    clip_path = _cairo_malloc (sizeof (cairo_clip_path_t));
     if (clip_path == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -807,7 +807,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 
 	n_boxes = 1;
 
-	rectangles = malloc(sizeof (cairo_rectangle_t));
+	rectangles = _cairo_malloc(sizeof (cairo_rectangle_t));
 	if (rectangles == NULL) {
 	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	    return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
@@ -823,7 +823,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
     }
 
  DONE:
-    list = malloc (sizeof (cairo_rectangle_list_t));
+    list = _cairo_malloc (sizeof (cairo_rectangle_list_t));
     if (list == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         free (rectangles);
diff --git a/src/cairo-deflate-stream.c b/src/cairo-deflate-stream.c
index bf2784a..0c05c9c 100644
--- a/src/cairo-deflate-stream.c
+++ b/src/cairo-deflate-stream.c
@@ -120,7 +120,7 @@ _cairo_deflate_stream_create (cairo_output_stream_t *output)
     if (output->status)
 	return _cairo_output_stream_create_in_error (output->status);
 
-    stream = malloc (sizeof (cairo_deflate_stream_t));
+    stream = _cairo_malloc (sizeof (cairo_deflate_stream_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index bb02dbf..901f945 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -1500,7 +1500,7 @@ _directfb_acquire_font_cache (cairo_directfb_surface_t     *surface,
 	    w  = MAX (w, x);
 
 	    /* Remember glyph location */
-	    rect = malloc (sizeof (DFBRectangle));
+	    rect = _cairo_malloc (sizeof (DFBRectangle));
 	    if (rect == NULL) {
 		_cairo_cache_thaw (scaled_font->glyphs);
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index 30c8d9f..8af82f9 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -517,7 +517,7 @@ cairo_toy_font_face_create (const char          *family,
     }
 
     /* Otherwise create it and insert into hash table. */
-    font_face = malloc (sizeof (cairo_toy_font_face_t));
+    font_face = _cairo_malloc (sizeof (cairo_toy_font_face_t));
     if (font_face == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto UNWIND_HASH_TABLE_LOCK;
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index 1f43528..3dc2fc6 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -88,7 +88,7 @@ cairo_font_options_create (void)
 {
     cairo_font_options_t *options;
 
-    options = malloc (sizeof (cairo_font_options_t));
+    options = _cairo_malloc (sizeof (cairo_font_options_t));
     if (!options) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_options_t *) &_cairo_font_options_nil;
@@ -120,7 +120,7 @@ cairo_font_options_copy (const cairo_font_options_t *original)
     if (cairo_font_options_status ((cairo_font_options_t *) original))
 	return (cairo_font_options_t *) &_cairo_font_options_nil;
 
-    options = malloc (sizeof (cairo_font_options_t));
+    options = _cairo_malloc (sizeof (cairo_font_options_t));
     if (!options) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_options_t *) &_cairo_font_options_nil;
diff --git a/src/cairo-freelist-private.h b/src/cairo-freelist-private.h
index 48791c2..86b6be3 100644
--- a/src/cairo-freelist-private.h
+++ b/src/cairo-freelist-private.h
@@ -49,7 +49,7 @@ cairo_private void
 _cairo_freelist_fini (cairo_freelist_t *freelist);
 
 /* Allocate a new node from the freelist.  If the freelist contains no
- * nodes, a new one will be allocated using malloc().  The caller is
+ * nodes, a new one will be allocated using _cairo_malloc().  The caller is
  * responsible for calling _cairo_freelist_free() or free() on the
  * returned node.  Returns %NULL on memory allocation error. */
 cairo_private void *
diff --git a/src/cairo-freelist.c b/src/cairo-freelist.c
index 3887f4b..c506470 100644
--- a/src/cairo-freelist.c
+++ b/src/cairo-freelist.c
@@ -50,7 +50,7 @@ _cairo_freelist_alloc (cairo_freelist_t *freelist)
 	freelist->first_free_node = node->next;
 	return (void*)node;
     }
-    return malloc (freelist->nodesize);
+    return _cairo_malloc (freelist->nodesize);
 }
 
 void *
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 37894b7..31e7b3a 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -205,7 +205,7 @@ _cairo_ft_unscaled_font_map_create (void)
      * detect some other call path. */
     assert (cairo_ft_unscaled_font_map == NULL);
 
-    font_map = malloc (sizeof (cairo_ft_unscaled_font_map_t));
+    font_map = _cairo_malloc (sizeof (cairo_ft_unscaled_font_map_t));
     if (font_map == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
@@ -456,7 +456,7 @@ _cairo_ft_unscaled_font_create_internal (cairo_bool_t from_face,
     }
 
     /* Otherwise create it and insert into hash table. */
-    unscaled = malloc (sizeof (cairo_ft_unscaled_font_t));
+    unscaled = _cairo_malloc (sizeof (cairo_ft_unscaled_font_t));
     if (unscaled == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	goto UNWIND_FONT_MAP_LOCK;
@@ -1780,7 +1780,7 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
     if (!face)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    scaled_font = malloc (sizeof(cairo_ft_scaled_font_t));
+    scaled_font = _cairo_malloc (sizeof(cairo_ft_scaled_font_t));
     if (scaled_font == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
@@ -2628,7 +2628,7 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
     }
 
     /* No match found, create a new one */
-    font_face = malloc (sizeof (cairo_ft_font_face_t));
+    font_face = _cairo_malloc (sizeof (cairo_ft_font_face_t));
     if (!font_face) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_face_t *)&_cairo_font_face_nil;
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 784bff9..eccb71a 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -788,7 +788,7 @@ _cairo_glitz_pattern_acquire_surface (cairo_pattern_t	              *pattern,
             if (size1 >= INT32_MAX - size2)
                 return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-            data = malloc (size1 + size2);
+            data = _cairo_malloc (size1 + size2);
         }
 
 	if (!data)
@@ -1585,7 +1585,7 @@ _cairo_glitz_area_create (cairo_glitz_root_area_t *root,
     cairo_glitz_area_t *area;
     int		       n = 4;
 
-    area = malloc (sizeof (cairo_glitz_area_t));
+    area = _cairo_malloc (sizeof (cairo_glitz_area_t));
     if (!area) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
@@ -1922,7 +1922,7 @@ _cairo_glitz_surface_font_init (cairo_glitz_surface_t *surface,
     if (!surface_format)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    font_private = malloc (sizeof (cairo_glitz_surface_font_private_t));
+    font_private = _cairo_malloc (sizeof (cairo_glitz_surface_font_private_t));
     if (!font_private)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -2008,7 +2008,7 @@ _cairo_glitz_surface_add_glyph (cairo_glitz_surface_t *surface,
     glyph_private = scaled_glyph->surface_private;
     if (glyph_private == NULL)
     {
-	glyph_private = malloc (sizeof (cairo_glitz_surface_glyph_private_t));
+	glyph_private = _cairo_malloc (sizeof (cairo_glitz_surface_glyph_private_t));
 	if (!glyph_private)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -2173,7 +2173,7 @@ _cairo_glitz_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font,
         if (size1 >= INT32_MAX - size2)
             goto FAIL1;
 
-	data = malloc (size1 + size2);
+	data = _cairo_malloc (size1 + size2);
 	if (!data) {
 	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	    goto FAIL1;
@@ -2476,7 +2476,7 @@ cairo_glitz_surface_create (glitz_surface_t *surface)
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER));
 
-    crsurface = malloc (sizeof (cairo_glitz_surface_t));
+    crsurface = _cairo_malloc (sizeof (cairo_glitz_surface_t));
     if (crsurface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 28a9538..f5c2257 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -225,7 +225,7 @@ _cairo_gstate_save (cairo_gstate_t **gstate, cairo_gstate_t **freelist)
 
     top = *freelist;
     if (top == NULL) {
-	top = malloc (sizeof (cairo_gstate_t));
+	top = _cairo_malloc (sizeof (cairo_gstate_t));
 	if (top == NULL)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     } else
diff --git a/src/cairo-hash.c b/src/cairo-hash.c
index 2317eb1..ad6c8b3 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -148,7 +148,7 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal)
 {
     cairo_hash_table_t *hash_table;
 
-    hash_table = malloc (sizeof (cairo_hash_table_t));
+    hash_table = _cairo_malloc (sizeof (cairo_hash_table_t));
     if (hash_table == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 21c9be4..57955a6 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -130,7 +130,7 @@ _cairo_image_surface_create_for_pixman_image (pixman_image_t		*pixman_image,
 {
     cairo_image_surface_t *surface;
 
-    surface = malloc (sizeof (cairo_image_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_image_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -402,7 +402,7 @@ _cairo_image_surface_create_with_content (cairo_content_t	content,
  * #cairo_surface_t *surface;
  *
  * stride = cairo_format_stride_for_width (format, width);
- * data = malloc (stride * height);
+ * data = _cairo_malloc (stride * height);
  * surface = cairo_image_surface_create_for_data (data, format,
  *						  width, height,
  *						  stride);
@@ -437,7 +437,7 @@ slim_hidden_def (cairo_format_stride_for_width);
  * cairo_image_surface_create_for_data:
  * @data: a pointer to a buffer supplied by the application in which
  *     to write contents. This pointer must be suitably aligned for any
- *     kind of variable, (for example, a pointer returned by malloc).
+ *     kind of variable, (for example, a pointer returned by _cairo_malloc).
  * @format: the format of pixels in the buffer
  * @width: the width of the image to be stored in the buffer
  * @height: the height of the image to be stored in the buffer
diff --git a/src/cairo-lzw.c b/src/cairo-lzw.c
index 1241225..fa9ee1c 100644
--- a/src/cairo-lzw.c
+++ b/src/cairo-lzw.c
@@ -72,7 +72,7 @@ _lzw_buf_init (lzw_buf_t *buf, int size)
     buf->pending = 0;
     buf->pending_bits = 0;
 
-    buf->data = malloc (size);
+    buf->data = _cairo_malloc (size);
     if (buf->data == NULL) {
 	buf->data_size = 0;
 	buf->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c
index b86cb51..0f7e080 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -83,7 +83,7 @@ _cairo_meta_surface_create (cairo_content_t	content,
 {
     cairo_meta_surface_t *meta;
 
-    meta = malloc (sizeof (cairo_meta_surface_t));
+    meta = _cairo_malloc (sizeof (cairo_meta_surface_t));
     if (meta == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -225,7 +225,7 @@ _cairo_meta_surface_paint (void			*abstract_surface,
     cairo_meta_surface_t *meta = abstract_surface;
     cairo_command_paint_t *command;
 
-    command = malloc (sizeof (cairo_command_paint_t));
+    command = _cairo_malloc (sizeof (cairo_command_paint_t));
     if (command == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -266,7 +266,7 @@ _cairo_meta_surface_mask (void			*abstract_surface,
     cairo_meta_surface_t *meta = abstract_surface;
     cairo_command_mask_t *command;
 
-    command = malloc (sizeof (cairo_command_mask_t));
+    command = _cairo_malloc (sizeof (cairo_command_mask_t));
     if (command == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -312,7 +312,7 @@ _cairo_meta_surface_stroke (void			*abstract_surface,
     cairo_meta_surface_t *meta = abstract_surface;
     cairo_command_stroke_t *command;
 
-    command = malloc (sizeof (cairo_command_stroke_t));
+    command = _cairo_malloc (sizeof (cairo_command_stroke_t));
     if (command == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -367,7 +367,7 @@ _cairo_meta_surface_fill (void			*abstract_surface,
     cairo_meta_surface_t *meta = abstract_surface;
     cairo_command_fill_t *command;
 
-    command = malloc (sizeof (cairo_command_fill_t));
+    command = _cairo_malloc (sizeof (cairo_command_fill_t));
     if (command == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -425,7 +425,7 @@ _cairo_meta_surface_show_text_glyphs (void			    *abstract_surface,
     cairo_meta_surface_t *meta = abstract_surface;
     cairo_command_show_text_glyphs_t *command;
 
-    command = malloc (sizeof (cairo_command_show_text_glyphs_t));
+    command = _cairo_malloc (sizeof (cairo_command_show_text_glyphs_t));
     if (command == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -445,7 +445,7 @@ _cairo_meta_surface_show_text_glyphs (void			    *abstract_surface,
     command->num_clusters = num_clusters;
 
     if (utf8_len) {
-	command->utf8 = malloc (utf8_len);
+	command->utf8 = _cairo_malloc (utf8_len);
 	if (command->utf8 == NULL) {
 	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    goto CLEANUP_ARRAYS;
@@ -511,7 +511,7 @@ _cairo_meta_surface_snapshot (void *abstract_other)
     cairo_meta_surface_t *other = abstract_other;
     cairo_meta_surface_t *meta;
 
-    meta = malloc (sizeof (cairo_meta_surface_t));
+    meta = _cairo_malloc (sizeof (cairo_meta_surface_t));
     if (meta == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -541,7 +541,7 @@ _cairo_meta_surface_intersect_clip_path (void		    *dst,
     cairo_command_intersect_clip_path_t *command;
     cairo_status_t status;
 
-    command = malloc (sizeof (cairo_command_intersect_clip_path_t));
+    command = _cairo_malloc (sizeof (cairo_command_intersect_clip_path_t));
     if (command == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c
index e4cef05..57716c9 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -167,7 +167,7 @@ cairo_os2_fini (void)
 /*
  * This function calls the allocation function depending on which
  * method was compiled into the library: it can be native allocation
- * (DosAllocMem/DosFreeMem) or C-Library based allocation (malloc/free).
+ * (DosAllocMem/DosFreeMem) or C-Library based allocation (_cairo_malloc/free).
  * Actually, for pixel buffers that we use this function for, cairo
  * uses _cairo_malloc_abc, so we use that here, too. And use the
  * change to check the size argument
@@ -193,7 +193,7 @@ void *_buffer_alloc (size_t a, size_t b, const unsigned int size)
     if (rc != NO_ERROR) {
         /* should there for some reason be another error, let's return
          * a null surface and free the buffer again, because that's
-         * how a malloc failure would look like
+         * how a _cairo_malloc failure would look like
          */
         if (rc != ERROR_NOT_ENOUGH_MEMORY && buffer) {
             DosFreeMem (buffer);
@@ -201,10 +201,10 @@ void *_buffer_alloc (size_t a, size_t b, const unsigned int size)
         return NULL;
     }
 #else
-    buffer = malloc (nbytes);
+    buffer = _cairo_malloc (nbytes);
 #endif
 
-    /* This does not seem to be needed, malloc'd space is usually
+    /* This does not seem to be needed, _cairo_malloc'd space is usually
      * already zero'd out!
      */
     /*
@@ -780,7 +780,7 @@ cairo_os2_surface_create (HPS hps_client_window,
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
     }
 
-    local_os2_surface = (cairo_os2_surface_t *) malloc (sizeof (cairo_os2_surface_t));
+    local_os2_surface = (cairo_os2_surface_t *) _cairo_malloc (sizeof (cairo_os2_surface_t));
     if (!local_os2_surface) {
         /* Not enough memory! */
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index bae6ac4..cc0419d 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -142,7 +142,7 @@ _cairo_output_stream_create (cairo_write_func_t		write_func,
 {
     cairo_output_stream_with_closure_t *stream;
 
-    stream = malloc (sizeof (cairo_output_stream_with_closure_t));
+    stream = _cairo_malloc (sizeof (cairo_output_stream_with_closure_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -167,7 +167,7 @@ _cairo_output_stream_create_in_error (cairo_status_t status)
     if (status == CAIRO_STATUS_WRITE_ERROR)
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
 
-    stream = malloc (sizeof (cairo_output_stream_t));
+    stream = _cairo_malloc (sizeof (cairo_output_stream_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -568,7 +568,7 @@ _cairo_output_stream_create_for_file (FILE *file)
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
     }
 
-    stream = malloc (sizeof *stream);
+    stream = _cairo_malloc (sizeof *stream);
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -601,7 +601,7 @@ _cairo_output_stream_create_for_filename (const char *filename)
 	}
     }
 
-    stream = malloc (sizeof *stream);
+    stream = _cairo_malloc (sizeof *stream);
     if (stream == NULL) {
 	fclose (file);
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
@@ -644,7 +644,7 @@ _cairo_memory_stream_create (void)
 {
     memory_stream_t *stream;
 
-    stream = malloc (sizeof *stream);
+    stream = _cairo_malloc (sizeof *stream);
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -695,7 +695,7 @@ _cairo_null_stream_create (void)
 {
     cairo_output_stream_t *stream;
 
-    stream = malloc (sizeof *stream);
+    stream = _cairo_malloc (sizeof *stream);
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index a94ca80..3a1615a 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -76,7 +76,7 @@ _cairo_paginated_surface_create (cairo_surface_t				*target,
     cairo_paginated_surface_t *surface;
     cairo_status_t status;
 
-    surface = malloc (sizeof (cairo_paginated_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_paginated_surface_t));
     if (surface == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index a915ada..19d33e6 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -149,7 +149,7 @@ _cairo_path_fixed_create (void)
 {
     cairo_path_fixed_t	*path;
 
-    path = malloc (sizeof (cairo_path_fixed_t));
+    path = _cairo_malloc (sizeof (cairo_path_fixed_t));
     if (!path) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
diff --git a/src/cairo-path.c b/src/cairo-path.c
index c6639f3..28f9657 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -301,7 +301,7 @@ _cairo_path_create_in_error (cairo_status_t status)
     if (status == CAIRO_STATUS_NO_MEMORY)
 	return (cairo_path_t*) &_cairo_path_nil;
 
-    path = malloc (sizeof (cairo_path_t));
+    path = _cairo_malloc (sizeof (cairo_path_t));
     if (path == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_path_t*) &_cairo_path_nil;
@@ -321,7 +321,7 @@ _cairo_path_create_internal (cairo_path_fixed_t *path_fixed,
 {
     cairo_path_t *path;
 
-    path = malloc (sizeof (cairo_path_t));
+    path = _cairo_malloc (sizeof (cairo_path_t));
     if (path == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_path_t*) &_cairo_path_nil;
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index bd3ed93..7c407c2 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -258,16 +258,16 @@ _cairo_pattern_create_copy (cairo_pattern_t	  **pattern,
 
     switch (other->type) {
     case CAIRO_PATTERN_TYPE_SOLID:
-	*pattern = malloc (sizeof (cairo_solid_pattern_t));
+	*pattern = _cairo_malloc (sizeof (cairo_solid_pattern_t));
 	break;
     case CAIRO_PATTERN_TYPE_SURFACE:
-	*pattern = malloc (sizeof (cairo_surface_pattern_t));
+	*pattern = _cairo_malloc (sizeof (cairo_surface_pattern_t));
 	break;
     case CAIRO_PATTERN_TYPE_LINEAR:
-	*pattern = malloc (sizeof (cairo_linear_pattern_t));
+	*pattern = _cairo_malloc (sizeof (cairo_linear_pattern_t));
 	break;
     case CAIRO_PATTERN_TYPE_RADIAL:
-	*pattern = malloc (sizeof (cairo_radial_pattern_t));
+	*pattern = _cairo_malloc (sizeof (cairo_radial_pattern_t));
 	break;
     }
     if (*pattern == NULL)
@@ -379,7 +379,7 @@ _cairo_pattern_create_solid (const cairo_color_t *color,
 
     if (pattern == NULL) {
 	/* None cached, need to create a new pattern. */
-	pattern = malloc (sizeof (cairo_solid_pattern_t));
+	pattern = _cairo_malloc (sizeof (cairo_solid_pattern_t));
     }
 
     if (pattern == NULL) {
@@ -532,7 +532,7 @@ cairo_pattern_create_for_surface (cairo_surface_t *surface)
     if (surface->status)
 	return (cairo_pattern_t*) _cairo_pattern_create_in_error (surface->status);
 
-    pattern = malloc (sizeof (cairo_surface_pattern_t));
+    pattern = _cairo_malloc (sizeof (cairo_surface_pattern_t));
     if (pattern == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_pattern_t *)&_cairo_pattern_nil.base;
@@ -578,7 +578,7 @@ cairo_pattern_create_linear (double x0, double y0, double x1, double y1)
 {
     cairo_linear_pattern_t *pattern;
 
-    pattern = malloc (sizeof (cairo_linear_pattern_t));
+    pattern = _cairo_malloc (sizeof (cairo_linear_pattern_t));
     if (pattern == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_pattern_t *) &_cairo_pattern_nil.base;
@@ -626,7 +626,7 @@ cairo_pattern_create_radial (double cx0, double cy0, double radius0,
 {
     cairo_radial_pattern_t *pattern;
 
-    pattern = malloc (sizeof (cairo_radial_pattern_t));
+    pattern = _cairo_malloc (sizeof (cairo_radial_pattern_t));
     if (pattern == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_pattern_t *) &_cairo_pattern_nil.base;
@@ -1574,7 +1574,7 @@ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t	     *pattern,
 
 	if (! _cairo_surface_is_similar (surface, dst, pattern->content)) {
 	    /* in the rare event of a substitute surface being returned (e.g.
-	     * malloc failure) don't cache the fallback surface */
+	     * _cairo_malloc failure) don't cache the fallback surface */
 	    *out = surface;
 	    goto NOCACHE;
 	}
diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 819318a..5e33b96 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -292,7 +292,7 @@ _word_wrap_stream_create (cairo_output_stream_t *output, int max_column)
     if (output->status)
 	return _cairo_output_stream_create_in_error (output->status);
 
-    stream = malloc (sizeof (word_wrap_stream_t));
+    stream = _cairo_malloc (sizeof (word_wrap_stream_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 44f0ed8..f55620b 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -233,7 +233,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t	*output,
     cairo_pdf_surface_t *surface;
     cairo_status_t status, status_ignored;
 
-    surface = malloc (sizeof (cairo_pdf_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_pdf_surface_t));
     if (surface == NULL) {
 	/* destroy stream on behalf of caller */
 	status = _cairo_output_stream_destroy (output);
@@ -4851,7 +4851,7 @@ _cairo_pdf_surface_show_text_glyphs (void			*abstract_surface,
 	group->source_res = pattern_res;
 
 	if (utf8_len) {
-	    group->utf8 = malloc (utf8_len);
+	    group->utf8 = _cairo_malloc (utf8_len);
 	    if (group->utf8 == NULL) {
 		_cairo_pdf_smask_group_destroy (group);
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index bfe424d..6b0cd30 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -699,7 +699,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream,
     cairo_status_t status, status_ignored;
     cairo_ps_surface_t *surface;
 
-    surface = malloc (sizeof (cairo_ps_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_ps_surface_t));
     if (surface == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto CLEANUP;
@@ -1720,7 +1720,7 @@ _string_array_stream_create (cairo_output_stream_t *output)
 {
     string_array_stream_t *stream;
 
-    stream = malloc (sizeof (string_array_stream_t));
+    stream = _cairo_malloc (sizeof (string_array_stream_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -1746,7 +1746,7 @@ _base85_array_stream_create (cairo_output_stream_t *output)
 {
     string_array_stream_t *stream;
 
-    stream = malloc (sizeof (string_array_stream_t));
+    stream = _cairo_malloc (sizeof (string_array_stream_t));
     if (stream == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -1910,7 +1910,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t    *surface,
     } else {
 	data_size = image->height * image->width * 3;
     }
-    data = malloc (data_size);
+    data = _cairo_malloc (data_size);
     if (data == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto bail1;
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index 94cc327..e350a44 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -157,7 +157,7 @@ _cairo_quartz_font_face_scaled_font_create (void *abstract_face,
     if (!_cairo_quartz_font_symbols_present)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    font = malloc(sizeof(cairo_quartz_scaled_font_t));
+    font = _cairo_malloc(sizeof(cairo_quartz_scaled_font_t));
     if (font == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -249,7 +249,7 @@ cairo_quartz_font_face_create_for_cgfont (CGFontRef font)
 
     quartz_font_ensure_symbols();
 
-    font_face = malloc (sizeof (cairo_quartz_font_face_t));
+    font_face = _cairo_malloc (sizeof (cairo_quartz_font_face_t));
     if (!font_face) {
 	_cairo_error (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_face_t *)&_cairo_font_face_nil;
@@ -285,7 +285,7 @@ _cairo_quartz_font_get_implementation (cairo_toy_font_face_t *toy_face,
     cairo_font_face_t *face;
     cairo_status_t status;
     const char *family = toy_face->family;
-    char *full_name = malloc(strlen(family) + 64); // give us a bit of room to tack on Bold, Oblique, etc.
+    char *full_name = _cairo_malloc(strlen(family) + 64); // give us a bit of room to tack on Bold, Oblique, etc.
     CFStringRef cgFontName = NULL;
     CGFontRef cgFont = NULL;
     int loop;
diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c
index 3eee2c1..4266270 100644
--- a/src/cairo-quartz-image-surface.c
+++ b/src/cairo-quartz-image-surface.c
@@ -233,7 +233,7 @@ cairo_quartz_image_surface_create (cairo_surface_t *surface)
     if (format != CAIRO_FORMAT_ARGB32 && format != CAIRO_FORMAT_RGB24)
 	return SURFACE_ERROR_INVALID_FORMAT;
 
-    qisurf = malloc(sizeof(cairo_quartz_image_surface_t));
+    qisurf = _cairo_malloc(sizeof(cairo_quartz_image_surface_t));
     if (qisurf == NULL)
 	return SURFACE_ERROR_NO_MEMORY;
 
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 163c9fb..ab82d72 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -690,7 +690,7 @@ CreateGradientFunction (cairo_gradient_pattern_t *gpat)
     };
 
     if (_cairo_pattern_create_copy (&pat, &gpat->base))
-	/* quartz doesn't deal very well with malloc failing, so there's
+	/* quartz doesn't deal very well with _cairo_malloc failing, so there's
 	 * not much point in us trying either */
 	return NULL;
 
@@ -774,7 +774,7 @@ CreateRepeatingGradientFunction (cairo_quartz_surface_t *surface,
     input_value_range[1] = 1.0 + 1.0 * rep_end;
 
     if (_cairo_pattern_create_copy (&pat, &gpat->base))
-	/* quartz doesn't deal very well with malloc failing, so there's
+	/* quartz doesn't deal very well with _cairo_malloc failing, so there's
 	 * not much point in us trying either */
 	return NULL;
 
@@ -953,7 +953,7 @@ _cairo_quartz_cairo_repeating_surface_pattern_to_quartz (cairo_quartz_surface_t
     if (image == NULL)
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
-    info = malloc(sizeof(SurfacePatternDrawInfo));
+    info = _cairo_malloc(sizeof(SurfacePatternDrawInfo));
     if (!info)
 	return CAIRO_STATUS_NO_MEMORY;
 
@@ -2447,7 +2447,7 @@ _cairo_quartz_surface_create_internal (CGContextRef cgContext,
     quartz_ensure_symbols();
 
     /* Init the base surface */
-    surface = malloc(sizeof(cairo_quartz_surface_t));
+    surface = _cairo_malloc(sizeof(cairo_quartz_surface_t));
     if (surface == NULL)
 	return (cairo_quartz_surface_t*) _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -2578,7 +2578,7 @@ cairo_quartz_surface_create (cairo_format_t format,
 	bitsPerComponent = 8;
 
 	/* The Apple docs say that for best performance, the stride and the data
-	 * pointer should be 16-byte aligned.  malloc already aligns to 16-bytes,
+	 * pointer should be 16-byte aligned.  _cairo_malloc already aligns to 16-bytes,
 	 * so we don't have to anything special on allocation.
 	 */
 	stride = width * 4;
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 066f637..3f2c4ac 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -162,7 +162,7 @@ _cairo_sub_font_glyph_create (unsigned long	scaled_font_glyph_index,
 {
     cairo_sub_font_glyph_t *sub_font_glyph;
 
-    sub_font_glyph = malloc (sizeof (cairo_sub_font_glyph_t));
+    sub_font_glyph = _cairo_malloc (sizeof (cairo_sub_font_glyph_t));
     if (sub_font_glyph == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
@@ -266,7 +266,7 @@ _cairo_sub_font_create (cairo_scaled_font_subsets_t	*parent,
     cairo_status_t status;
     cairo_scaled_font_subsets_glyph_t subset_glyph;
 
-    sub_font = malloc (sizeof (cairo_sub_font_t));
+    sub_font = _cairo_malloc (sizeof (cairo_sub_font_t));
     if (sub_font == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -359,7 +359,7 @@ _cairo_sub_font_glyph_lookup_unicode (cairo_sub_font_glyph_t *sub_font_glyph,
     if (unicode != (uint32_t) -1) {
 	len = _cairo_ucs4_to_utf8 (unicode, buf);
 	if (len > 0) {
-	    sub_font_glyph->utf8 = malloc (len + 1);
+	    sub_font_glyph->utf8 = _cairo_malloc (len + 1);
 	    if (sub_font_glyph->utf8 == NULL)
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -398,7 +398,7 @@ _cairo_sub_font_glyph_map_to_unicode (cairo_sub_font_glyph_t *sub_font_glyph,
 	    }
 	} else {
 	    /* No existing mapping. Use the requested mapping */
-	    sub_font_glyph->utf8 = malloc (utf8_len + 1);
+	    sub_font_glyph->utf8 = _cairo_malloc (utf8_len + 1);
 	    memcpy (sub_font_glyph->utf8, utf8, utf8_len);
 	    sub_font_glyph->utf8[utf8_len] = 0;
 	    sub_font_glyph->utf8_len = utf8_len;
@@ -596,7 +596,7 @@ _cairo_scaled_font_subsets_create_internal (cairo_subsets_type_t type)
 {
     cairo_scaled_font_subsets_t *subsets;
 
-    subsets = malloc (sizeof (cairo_scaled_font_subsets_t)); 
+    subsets = _cairo_malloc (sizeof (cairo_scaled_font_subsets_t)); 
     if (subsets == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
@@ -956,7 +956,7 @@ _cairo_string_init_key (cairo_string_entry_t *key, char *s)
 static cairo_status_t
 create_string_entry (char *s, cairo_string_entry_t **entry)
 {
-    *entry = malloc (sizeof (cairo_string_entry_t));
+    *entry = _cairo_malloc (sizeof (cairo_string_entry_t));
     if (*entry == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 3c5a959..5f62a63 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -319,7 +319,7 @@ _cairo_scaled_font_map_lock (void)
     CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
 
     if (cairo_scaled_font_map == NULL) {
-	cairo_scaled_font_map = malloc (sizeof (cairo_scaled_font_map_t));
+	cairo_scaled_font_map = _cairo_malloc (sizeof (cairo_scaled_font_map_t));
 	if (cairo_scaled_font_map == NULL)
 	    goto CLEANUP_MUTEX_LOCK;
 
@@ -427,7 +427,7 @@ _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t
     if (status)
 	return status;
 
-    placeholder_scaled_font = malloc (sizeof (cairo_scaled_font_t));
+    placeholder_scaled_font = _cairo_malloc (sizeof (cairo_scaled_font_t));
     if (placeholder_scaled_font == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -932,7 +932,7 @@ _cairo_scaled_font_create_in_error (cairo_status_t status)
     CAIRO_MUTEX_LOCK (_cairo_scaled_font_error_mutex);
     scaled_font = _cairo_scaled_font_nil_objects[status];
     if (scaled_font == NULL) {
-	scaled_font = malloc (sizeof (cairo_scaled_font_t));
+	scaled_font = _cairo_malloc (sizeof (cairo_scaled_font_t));
 	if (scaled_font == NULL) {
 	    CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_error_mutex);
 	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
@@ -2355,7 +2355,7 @@ _cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
 	/*
 	 * On miss, create glyph and insert into cache
 	 */
-	scaled_glyph = malloc (sizeof (cairo_scaled_glyph_t));
+	scaled_glyph = _cairo_malloc (sizeof (cairo_scaled_glyph_t));
 	if (scaled_glyph == NULL) {
 	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    goto CLEANUP;
diff --git a/src/cairo-skiplist.c b/src/cairo-skiplist.c
index e2b793e..0c3d7aa 100644
--- a/src/cairo-skiplist.c
+++ b/src/cairo-skiplist.c
@@ -294,7 +294,7 @@ alloc_node_for_level (cairo_skip_list_t *list, unsigned level)
 	list->freelists[freelist_level] = elt->prev;
 	return ELT_DATA(elt);
     }
-    return malloc (list->elt_size
+    return _cairo_malloc (list->elt_size
 		   + (FREELIST_MAX_LEVEL_FOR (level) - 1) * sizeof (skip_elt_t *));
 }
 
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index f392c8e..fed7f24 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -345,7 +345,7 @@ _cairo_svg_surface_create_for_document (cairo_svg_document_t	*document,
     cairo_surface_t *paginated;
     cairo_status_t status, status_ignored;
 
-    surface = malloc (sizeof (cairo_svg_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_svg_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -2371,7 +2371,7 @@ _cairo_svg_document_create (cairo_output_stream_t	 *output_stream,
     if (output_stream->status)
 	return output_stream->status;
 
-    document = malloc (sizeof (cairo_svg_document_t));
+    document = _cairo_malloc (sizeof (cairo_svg_document_t));
     if (document == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index e8be4b4..f30037d 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -173,7 +173,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     if (status)
 	return status;
 
-    name = malloc(size);
+    name = _cairo_malloc(size);
     if (name == NULL)
         return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -184,7 +184,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     if (status)
 	goto fail0;
 
-    font = malloc (sizeof (cairo_truetype_font_t));
+    font = _cairo_malloc (sizeof (cairo_truetype_font_t));
     if (font == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail0;
@@ -236,7 +236,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
         if ((be16_to_cpu (record->platform) == 1) &&
             (be16_to_cpu (record->encoding) == 0) &&
             (be16_to_cpu (record->name) == 4)) {
-            font->base.base_font = malloc (be16_to_cpu(record->length) + 1);
+            font->base.base_font = _cairo_malloc (be16_to_cpu(record->length) + 1);
             if (font->base.base_font) {
                 strncpy(font->base.base_font,
                         ((char*)name) + be16_to_cpu (name->strings_offset) + be16_to_cpu (record->offset),
@@ -251,7 +251,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
     name = NULL;
 
     if (font->base.base_font == NULL) {
-        font->base.base_font = malloc (30);
+        font->base.base_font = _cairo_malloc (30);
         if (font->base.base_font == NULL) {
 	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
             goto fail3;
@@ -583,7 +583,7 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font,
     else
 	size = sizeof (int32_t) * (font->num_glyphs_in_face + 1);
 
-    u.bytes = malloc (size);
+    u.bytes = _cairo_malloc (size);
     if (u.bytes == NULL)
 	return _cairo_truetype_font_set_error (font, CAIRO_STATUS_NO_MEMORY);
 
@@ -1123,7 +1123,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t    *truetype_subset,
     truetype_subset->descent = (double)font->base.descent/font->base.units_per_em;
 
     if (length) {
-	truetype_subset->data = malloc (length);
+	truetype_subset->data = _cairo_malloc (length);
 	if (truetype_subset->data == NULL) {
 	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    goto fail3;
@@ -1136,7 +1136,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t    *truetype_subset,
 
     if (num_strings) {
 	offsets_length = num_strings * sizeof (unsigned long);
-	truetype_subset->string_offsets = malloc (offsets_length);
+	truetype_subset->string_offsets = _cairo_malloc (offsets_length);
 	if (truetype_subset->string_offsets == NULL) {
 	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    goto fail4;
@@ -1208,7 +1208,12 @@ _cairo_truetype_reverse_cmap (cairo_scaled_font_t *scaled_font,
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     size = be16_to_cpu (map->length);
-    map = malloc (size);
+    /* minimum table size is 24 bytes */
+    if (size < 24)
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+
+
+    map = _cairo_malloc (size);
     if (map == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 83ddc44..56967b3 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -744,7 +744,7 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t	*type1_subset,
 
     length = font->header_size + font->data_size +
 	font->trailer_size;
-    type1_subset->data = malloc (length);
+    type1_subset->data = _cairo_malloc (length);
     if (type1_subset->data == NULL) {
         status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail3;
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index bbff33d..7f0a836 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -466,7 +466,7 @@ cairo_type1_font_subset_decrypt_eexec_segment (cairo_type1_font_subset_t *font)
     in = (unsigned char *) font->eexec_segment;
     end = (unsigned char *) in + font->eexec_segment_size;
 
-    font->cleartext = malloc (font->eexec_segment_size);
+    font->cleartext = _cairo_malloc (font->eexec_segment_size);
     if (font->cleartext == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -827,7 +827,7 @@ cairo_type1_font_subset_look_for_seac(cairo_type1_font_subset_t *font,
     int stack[5], sp, value;
     int command;
 
-    charstring = malloc (encrypted_charstring_length);
+    charstring = _cairo_malloc (encrypted_charstring_length);
     if (charstring == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1204,7 +1204,7 @@ cairo_type1_font_subset_generate (void       *abstract_font,
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     font->type1_length = font->face->stream->size;
-    font->type1_data = malloc (font->type1_length);
+    font->type1_data = _cairo_malloc (font->type1_length);
     if (font->type1_data == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail;
@@ -1338,7 +1338,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t		*type1_subset,
     length = font.base.header_size +
 	     font.base.data_size +
 	     font.base.trailer_size;
-    type1_subset->data = malloc (length);
+    type1_subset->data = _cairo_malloc (length);
     if (type1_subset->data == NULL)
 	goto fail3;
 
diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c
index c84f5f0..c56dc4a 100644
--- a/src/cairo-type3-glyph-surface.c
+++ b/src/cairo-type3-glyph-surface.c
@@ -54,7 +54,7 @@ _cairo_type3_glyph_surface_create (cairo_scaled_font_t	 		 *scaled_font,
     cairo_type3_glyph_surface_t *surface;
     cairo_matrix_t invert_y_axis;
 
-    surface = malloc (sizeof (cairo_type3_glyph_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_type3_glyph_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index ddcbc77..adba94e 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -420,7 +420,7 @@ _cairo_user_font_face_scaled_font_create (void                        *abstract_
 
     font_face->immutable = TRUE;
 
-    user_scaled_font = malloc (sizeof (cairo_user_scaled_font_t));
+    user_scaled_font = _cairo_malloc (sizeof (cairo_user_scaled_font_t));
     if (user_scaled_font == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -556,7 +556,7 @@ cairo_user_font_face_create (void)
 {
     cairo_user_font_face_t *font_face;
 
-    font_face = malloc (sizeof (cairo_user_font_face_t));
+    font_face = _cairo_malloc (sizeof (cairo_user_font_face_t));
     if (!font_face) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_face_t *)&_cairo_font_face_nil;
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index a9a9353..78f6538 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -292,7 +292,7 @@ _win32_scaled_font_create (LOGFONTW                   *logfont,
     if (hdc == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    f = malloc (sizeof(cairo_win32_scaled_font_t));
+    f = _cairo_malloc (sizeof(cairo_win32_scaled_font_t));
     if (f == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -437,7 +437,7 @@ _win32_scaled_font_get_unscaled_hfont (cairo_win32_scaled_font_t *scaled_font,
 	if (! otm_size)
 	    return _cairo_win32_print_gdi_error ("_win32_scaled_font_get_unscaled_hfont:GetOutlineTextMetrics");
 
-	otm = malloc (otm_size);
+	otm = _cairo_malloc (otm_size);
 	if (otm == NULL)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1531,7 +1531,7 @@ _cairo_win32_scaled_font_index_to_ucs4 (void		*abstract_font,
 	goto exit1;
     }
 
-    glyph_set = malloc (res);
+    glyph_set = _cairo_malloc (res);
     if (glyph_set == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto exit1;
@@ -1707,7 +1707,7 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
 	goto CLEANUP_FONT;
     }
 
-    ptr = buffer = malloc (bytesGlyph);
+    ptr = buffer = _cairo_malloc (bytesGlyph);
     if (!buffer) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto CLEANUP_FONT;
@@ -1931,7 +1931,7 @@ cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont, HFONT font)
 {
     cairo_win32_font_face_t *font_face;
 
-    font_face = malloc (sizeof (cairo_win32_font_face_t));
+    font_face = _cairo_malloc (sizeof (cairo_win32_font_face_t));
     if (!font_face) {
         _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         return (cairo_font_face_t *)&_cairo_font_face_nil;
diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 2c2f061..a288043 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -736,8 +736,8 @@ _cairo_win32_printing_surface_paint_linear_pattern (cairo_win32_surface_t *surfa
     num_rects = num_stops - 1;
 
     /* Add an extra four points and two rectangles for EXTEND_PAD */
-    vert = malloc (sizeof (TRIVERTEX) * (num_rects*2*num_ranges + 4));
-    rect = malloc (sizeof (GRADIENT_RECT) * (num_rects*num_ranges + 2));
+    vert = _cairo_malloc (sizeof (TRIVERTEX) * (num_rects*2*num_ranges + 4));
+    rect = _cairo_malloc (sizeof (GRADIENT_RECT) * (num_rects*num_ranges + 2));
 
     for (i = 0; i < num_ranges*num_rects; i++) {
 	vert[i*2].y = (LONG) clip.top;
@@ -1553,7 +1553,7 @@ cairo_win32_printing_surface_create (HDC hdc)
     cairo_surface_t *paginated;
     RECT rect;
 
-    surface = malloc (sizeof (cairo_win32_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 4327621..b4cb861 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -333,7 +333,7 @@ _cairo_win32_surface_create_for_dc (HDC             original_dc,
     unsigned char *bits;
     int rowstride;
 
-    surface = malloc (sizeof (cairo_win32_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -1501,7 +1501,7 @@ _cairo_win32_surface_set_clip_region (void           *abstract_surface,
 	     */
 
 	    data_size = sizeof (RGNDATAHEADER) + num_boxes * sizeof (RECT);
-	    data = malloc (data_size);
+	    data = _cairo_malloc (data_size);
 	    if (!data) {
 		_cairo_region_boxes_fini (region, boxes);
 		return _cairo_error(CAIRO_STATUS_NO_MEMORY);
@@ -1740,7 +1740,7 @@ cairo_win32_surface_create (HDC hdc)
     /* Assume that everything coming in as a HDC is RGB24 */
     format = CAIRO_FORMAT_RGB24;
 
-    surface = malloc (sizeof (cairo_win32_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -2122,7 +2122,7 @@ _cairo_win32_debug_dump_hrgn (HRGN rgn, char *header)
     }
 
     z = GetRegionData(rgn, 0, NULL);
-    rd = (RGNDATA*) malloc(z);
+    rd = (RGNDATA*) _cairo_malloc(z);
     z = GetRegionData(rgn, z, rd);
 
     fprintf (stderr, " %d rects, bounds: %d %d %d %d\n", rd->rdh.nCount, rd->rdh.rcBound.left, rd->rdh.rcBound.top, rd->rdh.rcBound.right - rd->rdh.rcBound.left, rd->rdh.rcBound.bottom - rd->rdh.rcBound.top);
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 18426e7..d02f3e2 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -567,7 +567,7 @@ _draw_image_surface (cairo_xcb_surface_t    *surface,
 	uint8_t *data_line, *image_line;
 	int data_bpl = _bytes_per_line(surface->dpy, width, bpp);
 	data_len = height * data_bpl;
-	data_line = data = malloc(data_len);
+	data_line = data = _cairo_malloc(data_len);
 	if (data == NULL)
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -1740,7 +1740,7 @@ _cairo_xcb_surface_create_internal (xcb_connection_t	     *dpy,
     const xcb_query_extension_reply_t *er;
     const xcb_render_query_version_reply_t *r = NULL;
 
-    surface = malloc (sizeof (cairo_xcb_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_xcb_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
@@ -2004,7 +2004,7 @@ _cairo_xcb_surface_font_init (xcb_connection_t		    *dpy,
 {
     cairo_xcb_surface_font_private_t	*font_private;
 
-    font_private = malloc (sizeof (cairo_xcb_surface_font_private_t));
+    font_private = _cairo_malloc (sizeof (cairo_xcb_surface_font_private_t));
     if (!font_private)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -2122,7 +2122,7 @@ _cairo_xcb_surface_add_glyph (xcb_connection_t *dpy,
 	    unsigned char   *d;
 	    unsigned char   *new, *n;
 
-	    new = malloc (c);
+	    new = _cairo_malloc (c);
 	    if (!new) {
 		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 		goto BAIL;
@@ -2148,7 +2148,7 @@ _cairo_xcb_surface_add_glyph (xcb_connection_t *dpy,
 	    unsigned char   *d;
 	    unsigned char   *new, *n;
 
-	    new = malloc (c);
+	    new = _cairo_malloc (c);
 	    if (new == NULL) {
 		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 		goto BAIL;
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index b2e2755..b1701a1 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -245,7 +245,7 @@ _cairo_xlib_display_get (Display *dpy)
 	goto UNLOCK;
     }
 
-    display = malloc (sizeof (cairo_xlib_display_t));
+    display = _cairo_malloc (sizeof (cairo_xlib_display_t));
     if (display == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	goto UNLOCK;
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
index 37e3418..b778464 100644
--- a/src/cairo-xlib-screen.c
+++ b/src/cairo-xlib-screen.c
@@ -374,7 +374,7 @@ _cairo_xlib_screen_info_get (cairo_xlib_display_t *display, Screen *screen)
     if (info != NULL) {
 	info = _cairo_xlib_screen_info_reference (info);
     } else {
-	info = malloc (sizeof (cairo_xlib_screen_info_t));
+	info = _cairo_malloc (sizeof (cairo_xlib_screen_info_t));
 	if (info != NULL) {
 	    CAIRO_REFERENCE_COUNT_INIT (&info->ref_count, 2); /* Add one for display cache */
 	    CAIRO_MUTEX_INIT (info->mutex);
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index c433df0..65731a4 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2540,7 +2540,7 @@ _cairo_xlib_surface_create_internal (Display		       *dpy,
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
     }
 
-    surface = malloc (sizeof (cairo_xlib_surface_t));
+    surface = _cairo_malloc (sizeof (cairo_xlib_surface_t));
     if (surface == NULL) {
 	_cairo_xlib_screen_info_destroy (screen_info);
 	_cairo_xlib_display_destroy (display);
@@ -3134,7 +3134,7 @@ _cairo_xlib_surface_font_init (Display		    *dpy,
     cairo_xlib_surface_font_private_t	*font_private;
     int i;
 
-    font_private = malloc (sizeof (cairo_xlib_surface_font_private_t));
+    font_private = _cairo_malloc (sizeof (cairo_xlib_surface_font_private_t));
     if (font_private == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
@@ -3263,7 +3263,7 @@ _cairo_xlib_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
 	}
 
 	if (to_free == NULL) {
-	    to_free = malloc (sizeof (cairo_xlib_font_glyphset_free_glyphs_t));
+	    to_free = _cairo_malloc (sizeof (cairo_xlib_font_glyphset_free_glyphs_t));
 	    if (to_free == NULL) {
 		_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 		return; /* XXX cannot propagate failure */
@@ -3519,7 +3519,7 @@ _cairo_xlib_surface_add_glyph (Display *dpy,
 	    unsigned char   *d;
 	    unsigned char   *new, *n;
 
-	    new = malloc (c);
+	    new = _cairo_malloc (c);
 	    if (!new) {
 		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 		goto BAIL;
@@ -3545,7 +3545,7 @@ _cairo_xlib_surface_add_glyph (Display *dpy,
 	    unsigned char   *d;
 	    unsigned char   *new, *n;
 
-	    new = malloc (c);
+	    new = _cairo_malloc (c);
 	    if (new == NULL) {
 		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 		goto BAIL;
diff --git a/src/cairo-xlib-visual.c b/src/cairo-xlib-visual.c
index f6eb1ee..6268e12 100644
--- a/src/cairo-xlib-visual.c
+++ b/src/cairo-xlib-visual.c
@@ -77,7 +77,7 @@ _cairo_xlib_visual_info_create (Display *dpy,
     for (i = 0; i < RAMP_SIZE; i++)
 	ramp_index_to_short[i] = (0xffff * i + ((RAMP_SIZE-1)>>1)) / (RAMP_SIZE-1);
 
-    info = malloc (sizeof (cairo_xlib_visual_info_t));
+    info = _cairo_malloc (sizeof (cairo_xlib_visual_info_t));
     if (info == NULL)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
diff --git a/src/cairo.c b/src/cairo.c
index a2e9842..d3117ee 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -151,7 +151,7 @@ cairo_create (cairo_surface_t *target)
     if (target && target->status == CAIRO_STATUS_NO_MEMORY)
 	return (cairo_t *) &_cairo_nil;
 
-    cr = malloc (sizeof (cairo_t));
+    cr = _cairo_malloc (sizeof (cairo_t));
     if (cr == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_t *) &_cairo_nil;
@@ -2534,7 +2534,7 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status)
     if (status == CAIRO_STATUS_NO_MEMORY)
         return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
 
-    list = malloc (sizeof (cairo_rectangle_list_t));
+    list = _cairo_malloc (sizeof (cairo_rectangle_list_t));
     if (list == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
         return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
diff --git a/src/cairoint.h b/src/cairoint.h
index 7fa8cde..299a19b 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -140,7 +140,7 @@ _cairo_win32_tmpfile (void);
 
 /* Size in bytes of buffer to use off the stack per functions.
  * Mostly used by text functions.  For larger allocations, they'll
- * malloc(). */
+ * _cairo_malloc(). */
 #ifndef CAIRO_STACK_BUFFER_SIZE
 #define CAIRO_STACK_BUFFER_SIZE (512 * sizeof (int))
 #endif
diff --git a/src/test-fallback-surface.c b/src/test-fallback-surface.c
index 883941d..3b7d688 100644
--- a/src/test-fallback-surface.c
+++ b/src/test-fallback-surface.c
@@ -78,7 +78,7 @@ _cairo_test_fallback_surface_create (cairo_content_t	content,
     if (cairo_surface_status (backing))
 	return backing;
 
-    surface = malloc (sizeof (test_fallback_surface_t));
+    surface = _cairo_malloc (sizeof (test_fallback_surface_t));
     if (surface == NULL) {
 	cairo_surface_destroy (backing);
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c
index 6038430..9d5d9b7 100644
--- a/src/test-meta-surface.c
+++ b/src/test-meta-surface.c
@@ -76,7 +76,7 @@ _cairo_test_meta_surface_create (cairo_content_t	content,
     test_meta_surface_t *surface;
     cairo_status_t status;
 
-    surface = malloc (sizeof (test_meta_surface_t));
+    surface = _cairo_malloc (sizeof (test_meta_surface_t));
     if (surface == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c
index 354f95d..2fe459d 100644
--- a/src/test-paginated-surface.c
+++ b/src/test-paginated-surface.c
@@ -79,7 +79,7 @@ _cairo_test_paginated_surface_create_for_data (unsigned char		*data,
     if (status)
 	return target;
 
-    surface = malloc (sizeof (test_paginated_surface_t));
+    surface = _cairo_malloc (sizeof (test_paginated_surface_t));
     if (surface == NULL) {
 	cairo_surface_destroy (target);
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
