From 815e3fc44098466b138092ef35137c5f71de14f9 Mon Sep 17 00:00:00 2001 From: mental Date: Sun, 28 May 2006 19:51:13 +0000 Subject: [PATCH] replace nr_new() with g_new(), and try to converge on using the glib allocator a little more instead of the others (aside from libgc) --- ChangeLog | 20 ++++++++++++++++ src/dialogs/clonetiler.cpp | 3 ++- src/dialogs/iconpreview.cpp | 3 ++- src/dialogs/stroke-style.cpp | 5 ++-- src/display/curve.cpp | 17 +++++++------- src/display/sp-canvas.cpp | 8 +++---- src/dyna-draw-context.cpp | 3 ++- src/extension/internal/gnome.cpp | 2 +- src/extension/internal/pdf.cpp | 5 ++-- src/extension/internal/ps.cpp | 5 ++-- src/extension/internal/win32.cpp | 5 ++-- src/file.cpp | 5 ++-- src/inkview.cpp | 7 +++--- src/libnr/nr-macros.h | 4 ---- src/libnr/nr-object.cpp | 11 +++++---- src/libnr/nr-path.cpp | 3 ++- src/libnr/nr-pixblock-pattern.cpp | 3 ++- src/libnr/nr-pixblock.cpp | 35 ++++++++++++++-------------- src/libnr/nr-svp-render.cpp | 5 ++-- src/libnr/nr-svp.cpp | 11 +++++---- src/libnrtype/FontFactory.cpp | 23 +++++++++--------- src/libnrtype/Layout-TNG-Output.cpp | 3 ++- src/libnrtype/nr-type-primitives.cpp | 7 +++--- src/path-chemistry.cpp | 3 ++- src/sp-marker.cpp | 2 +- src/splivarot.cpp | 3 ++- src/ui/widget/icon-widget.cpp | 3 ++- src/widgets/icon.cpp | 9 +++---- 28 files changed, 126 insertions(+), 87 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5a4f63f3..b475a4c83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2006-05-28 MenTaLguY + + * src/dialogs/clonetiler.cpp, src/dialogs/iconpreview.cpp, + src/dialogs/stroke-style.cpp, src/display/curve.cpp, + src/display/sp-canvas.cpp, src/dyna-draw-context.cpp, + src/extension/internal/gnome.cpp, src/extension/internal/pdf.cpp, + src/extension/internal/ps.cpp, src/extension/internal/win32.cpp, + src/file.cpp, src/inkview.cpp, src/libnr/nr-macros.h, + src/libnr/nr-object.cpp, src/libnr/nr-path.cpp, + src/libnr/nr-pixblock.cpp, src/libnr/nr-pixblock-pattern.cpp, + src/libnr/nr-svp.cpp, src/libnr/nr-svp-render.cpp, + src/libnrtype/FontFactory.cpp, src/libnrtype/Layout-TNG-Output.cpp, + src/libnrtype/nr-type-primitives.cpp, src/path-chemistry.cpp, + src/splivarot.cpp, src/sp-marker.cpp, src/ui/widget/icon-widget.cpp, + src/widgets/icon.cpp: + + replace nr_new() with g_new(), and try to converge on using the + glib allocator a little more instead of the others (aside from + libgc) + 2006-05-28 MenTaLguY * share/icons/icons.svg: diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 64edcbfd5..e47437c72 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -13,6 +13,7 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include #include #include @@ -778,7 +779,7 @@ clonetiler_trace_pick (NR::Rect box) int height = ibox.y1 - ibox.y0; /* Set up pixblock */ - guchar *px = nr_new(guchar, 4 * width * height); + guchar *px = g_new(guchar, 4 * width * height); memset(px, 0x00, 4 * width * height); /* Render */ diff --git a/src/dialogs/iconpreview.cpp b/src/dialogs/iconpreview.cpp index 6641b3bfb..90f48a4a6 100644 --- a/src/dialogs/iconpreview.cpp +++ b/src/dialogs/iconpreview.cpp @@ -19,6 +19,7 @@ #include +#include #include //for GTK_RESPONSE* types #include #include @@ -160,7 +161,7 @@ IconPreviewPanel::IconPreviewPanel() : pixMem[i] = new guchar[4 * sizes[i] * sizes[i]]; memset( pixMem[i], 0x00, 4 * sizes[i] * sizes[i] ); - GdkPixbuf *pb = gdk_pixbuf_new_from_data( pixMem[i], GDK_COLORSPACE_RGB, TRUE, 8, sizes[i], sizes[i], sizes[i] * 4, /*(GdkPixbufDestroyNotify)nr_free*/NULL, NULL ); + GdkPixbuf *pb = gdk_pixbuf_new_from_data( pixMem[i], GDK_COLORSPACE_RGB, TRUE, 8, sizes[i], sizes[i], sizes[i] * 4, /*(GdkPixbufDestroyNotify)g_free*/NULL, NULL ); GtkImage* img = GTK_IMAGE( gtk_image_new_from_pixbuf( pb ) ); images[i] = Glib::wrap(img); Glib::ustring label(*labels[i]); diff --git a/src/dialogs/stroke-style.cpp b/src/dialogs/stroke-style.cpp index 5fefb8aa9..8f345d837 100644 --- a/src/dialogs/stroke-style.cpp +++ b/src/dialogs/stroke-style.cpp @@ -23,6 +23,7 @@ +#include #include #include @@ -590,7 +591,7 @@ sp_marker_prev_new(unsigned size, gchar const *mname, ua.y1 = MIN(ibox.y1, area.y1); /* Set up pixblock */ - guchar *px = nr_new(guchar, 4 * size * size); + guchar *px = g_new(guchar, 4 * size * size); memset(px, 0x00, 4 * size * size); /* Render */ @@ -609,7 +610,7 @@ sp_marker_prev_new(unsigned size, gchar const *mname, GDK_COLORSPACE_RGB, TRUE, 8, size, size, size * 4, - (GdkPixbufDestroyNotify)nr_free, + (GdkPixbufDestroyNotify)g_free, NULL)); return pb; } diff --git a/src/display/curve.cpp b/src/display/curve.cpp index bbbba09f0..9e571fdd0 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -16,6 +16,7 @@ */ +#include #include #include #include @@ -56,7 +57,7 @@ sp_curve_new_sized(gint length) SPCurve *curve = g_new(SPCurve, 1); curve->refcount = 1; - curve->_bpath = nr_new(NArtBpath, length); + curve->_bpath = g_new(NArtBpath, length); curve->_bpath->code = NR_END; curve->end = 0; curve->length = length; @@ -80,7 +81,7 @@ sp_curve_new_from_bpath(NArtBpath *bpath) g_return_val_if_fail(bpath != NULL, NULL); SPCurve *curve = sp_curve_new_from_foreign_bpath(bpath); - nr_free(bpath); + g_free(bpath); return curve; } @@ -99,7 +100,7 @@ SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]) g_return_val_if_fail(new_bpath != NULL, NULL); } else { unsigned const len = sp_bpath_length(bpath); - new_bpath = nr_new(NArtBpath, len); + new_bpath = g_new(NArtBpath, len); memcpy(new_bpath, bpath, len * sizeof(NArtBpath)); } @@ -152,7 +153,7 @@ sp_curve_unref(SPCurve *curve) if (curve->refcount < 1) { if (curve->_bpath) { - nr_free(curve->_bpath); + g_free(curve->_bpath); } g_free(curve); } @@ -175,7 +176,7 @@ sp_curve_ensure_space(SPCurve *curve, gint space) if (space < SP_CURVE_LENSTEP) space = SP_CURVE_LENSTEP; - curve->_bpath = nr_renew(curve->_bpath, NArtBpath, curve->length + space); + curve->_bpath = g_renew(NArtBpath, curve->_bpath, curve->length + space); curve->length += space; } @@ -936,7 +937,7 @@ static bool sp_bpath_good(NArtBpath const bpath[]) */ static NArtBpath *sp_bpath_clean(NArtBpath const bpath[]) { - NArtBpath *new_bpath = nr_new(NArtBpath, sp_bpath_length(bpath)); + NArtBpath *new_bpath = g_new(NArtBpath, sp_bpath_length(bpath)); NArtBpath const *bp = bpath; NArtBpath *np = new_bpath; @@ -956,14 +957,14 @@ static NArtBpath *sp_bpath_clean(NArtBpath const bpath[]) } if (np == new_bpath) { - nr_free(new_bpath); + g_free(new_bpath); return NULL; } np->code = NR_END; np += 1; - new_bpath = nr_renew(new_bpath, NArtBpath, np - new_bpath); + new_bpath = g_renew(NArtBpath, new_bpath, np - new_bpath); return new_bpath; } diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index edd429f0d..8ce4a35b4 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -994,7 +994,7 @@ shutdown_transients (SPCanvas *canvas) if (canvas->need_redraw) { canvas->need_redraw = FALSE; } - if ( canvas->tiles ) free(canvas->tiles); + if ( canvas->tiles ) g_free(canvas->tiles); canvas->tiles=NULL; canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0; canvas->tileH=canvas->tileV=0; @@ -2029,7 +2029,7 @@ inline int sp_canvas_tile_ceil(int x) void sp_canvas_resize_tiles(SPCanvas* canvas,int nl,int nt,int nr,int nb) { if ( nl >= nr || nt >= nb ) { - if ( canvas->tiles ) free(canvas->tiles); + if ( canvas->tiles ) g_free(canvas->tiles); canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0; canvas->tileH=canvas->tileV=0; canvas->tiles=NULL; @@ -2041,7 +2041,7 @@ void sp_canvas_resize_tiles(SPCanvas* canvas,int nl,int nt,int nr,int nb) int tb=sp_canvas_tile_ceil(nb); int nh=tr-tl,nv=tb-tt; - uint8_t* ntiles=(uint8_t*)malloc(nh*nv*sizeof(uint8_t)); + uint8_t* ntiles=(uint8_t*)g_malloc(nh*nv*sizeof(uint8_t)); for (int i=tl;itiles ) free(canvas->tiles); + if ( canvas->tiles ) g_free(canvas->tiles); canvas->tiles=ntiles; canvas->tLeft=tl; canvas->tTop=tt; diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index acbd6ae80..ef0f47397 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -29,6 +29,7 @@ #include "display/canvas-bpath.h" #include "display/bezier-utils.h" +#include #include "macros.h" #include "document.h" #include "selection.h" @@ -668,7 +669,7 @@ set_to_accumulated(SPDynaDrawContext *dc) abp = nr_artpath_affine(sp_curve_first_bpath(dc->accumulated), sp_desktop_dt2root_affine(desktop)); str = sp_svg_write_path(abp); g_assert( str != NULL ); - nr_free(abp); + g_free(abp); dc->repr->setAttribute("d", str); g_free(str); } else { diff --git a/src/extension/internal/gnome.cpp b/src/extension/internal/gnome.cpp index 6c6563e7e..4bdec5f98 100644 --- a/src/extension/internal/gnome.cpp +++ b/src/extension/internal/gnome.cpp @@ -423,7 +423,7 @@ nr_artpath_to_art_bpath(NArtBpath const *s) i = 0; while (s[i].code != NR_END) i += 1; - ArtBpath* d = nr_new (ArtBpath, i + 1); + ArtBpath* d = g_new (ArtBpath, i + 1); i = 0; while (s[i].code != NR_END) { diff --git a/src/extension/internal/pdf.cpp b/src/extension/internal/pdf.cpp index ed98c4a29..938f570b7 100644 --- a/src/extension/internal/pdf.cpp +++ b/src/extension/internal/pdf.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -405,7 +406,7 @@ PrintPDF::finish(Inkscape::Extension::Print *mod) nr_arena_item_set_transform(mod->root, &affine); - guchar *const px = nr_new(guchar, 4 * width * 64); + guchar *const px = g_new(guchar, 4 * width * 64); for (int y = 0; y < height; y += 64) { /* Set area of interest. */ @@ -439,7 +440,7 @@ PrintPDF::finish(Inkscape::Extension::Print *mod) print_image(_stream, px, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, 4 * width, &imgt); } - nr_free(px); + g_free(px); } pdf_file->end_page(page_stream); diff --git a/src/extension/internal/ps.cpp b/src/extension/internal/ps.cpp index c814637c6..a72b88461 100644 --- a/src/extension/internal/ps.cpp +++ b/src/extension/internal/ps.cpp @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -451,7 +452,7 @@ PrintPS::finish(Inkscape::Extension::Print *mod) nr_arena_item_set_transform(mod->root, &affine); - guchar *const px = nr_new(guchar, 4 * width * 64); + guchar *const px = g_new(guchar, 4 * width * 64); for (int y = 0; y < height; y += 64) { /* Set area of interest. */ @@ -485,7 +486,7 @@ PrintPS::finish(Inkscape::Extension::Print *mod) print_image(_stream, px, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, 4 * width, &imgt); } - nr_free(px); + g_free(px); } fprintf(_stream, "showpage\n"); diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp index 335a77a09..51dbd3a00 100644 --- a/src/extension/internal/win32.cpp +++ b/src/extension/internal/win32.cpp @@ -13,6 +13,7 @@ # include "config.h" #endif +#include #include #include @@ -312,7 +313,7 @@ PrintWin32::finish (Inkscape::Extension::Print *mod) width = x1 - x0; height = y1 - y0; - px = nr_new (unsigned char, 4 * 64 * width); + px = g_new (unsigned char, 4 * 64 * width); sheight = 64; /* Printing goes here */ @@ -368,7 +369,7 @@ PrintWin32::finish (Inkscape::Extension::Print *mod) nr_pixblock_release (&pb); } - nr_free (px); + g_free (px); res = EndPage (_hDC); res = EndDoc (_hDC); diff --git a/src/file.cpp b/src/file.cpp index 4d96899da..de9b615aa 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -25,6 +25,7 @@ # include "config.h" #endif +#include #include #include "document-private.h" @@ -1170,10 +1171,10 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, write_status = sp_png_write_rgba_striped(filename, width, height, sp_export_get_rows, &ebp); nr_pixelstore_64K_free(ebp.px); } else { - ebp.px = nr_new(guchar, 4 * 64 * width); + ebp.px = g_new(guchar, 4 * 64 * width); ebp.sheight = 64; write_status = sp_png_write_rgba_striped(filename, width, height, sp_export_get_rows, &ebp); - nr_free(ebp.px); + g_free(ebp.px); } // Hide items diff --git a/src/inkview.cpp b/src/inkview.cpp index 8be261dcd..0e2179283 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -191,7 +192,7 @@ main (int argc, const char **argv) ss.size = 32; ss.length = 0; ss.current = 0; - ss.slides = nr_new (char *, ss.size); + ss.slides = g_new (char *, ss.size); ss.current = 0; ss.doc = NULL; ss.view = NULL; @@ -230,7 +231,7 @@ main (int argc, const char **argv) if (ss.length >= ss.size) { /* Expand */ ss.size <<= 1; - ss.slides = nr_renew (ss.slides, char *, ss.size); + ss.slides = g_renew (char *, ss.slides, ss.size); } ss.doc = sp_document_new_from_mem ((const gchar *)gba->data, @@ -252,7 +253,7 @@ main (int argc, const char **argv) if (ss.length >= ss.size) { /* Expand */ ss.size <<= 1; - ss.slides = nr_renew (ss.slides, char *, ss.size); + ss.slides = g_renew (char *, ss.slides, ss.size); } diff --git a/src/libnr/nr-macros.h b/src/libnr/nr-macros.h index 74a627ae7..616504c6f 100644 --- a/src/libnr/nr-macros.h +++ b/src/libnr/nr-macros.h @@ -17,10 +17,6 @@ #endif #include -#define nr_new(t,n) ((t *) malloc ((n) * sizeof (t))) -#define nr_free free -#define nr_renew(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) - #ifndef TRUE #define TRUE (!0) #endif diff --git a/src/libnr/nr-object.cpp b/src/libnr/nr-object.cpp index feffbd884..12f57bd81 100644 --- a/src/libnr/nr-object.cpp +++ b/src/libnr/nr-object.cpp @@ -15,6 +15,7 @@ #include +#include #include #include "nr-object.h" @@ -77,7 +78,7 @@ NRType nr_object_register_type(NRType parent, { if (classes_len >= classes_size) { classes_size += 32; - classes = nr_renew (classes, NRObjectClass *, classes_size); + classes = g_renew (NRObjectClass *, classes, classes_size); if (classes_len == 0) { classes[0] = NULL; classes_len = 1; @@ -251,7 +252,7 @@ static void nr_active_object_finalize(NRObject *object) listener->vector->dispose(object, listener->data); } } - free (aobject->callbacks); + g_free (aobject->callbacks); } ((NRObjectClass *) (parent_class))->finalize(object); @@ -263,7 +264,7 @@ void nr_active_object_add_listener(NRActiveObject *object, void *data) { if (!object->callbacks) { - object->callbacks = (NRObjectCallbackBlock*) malloc(sizeof(NRObjectCallbackBlock)); + object->callbacks = (NRObjectCallbackBlock*)g_malloc(sizeof(NRObjectCallbackBlock)); object->callbacks->size = 1; object->callbacks->length = 0; } @@ -271,7 +272,7 @@ void nr_active_object_add_listener(NRActiveObject *object, if (object->callbacks->length >= object->callbacks->size) { int newsize = object->callbacks->size << 1; object->callbacks = (NRObjectCallbackBlock *) - realloc(object->callbacks, sizeof(NRObjectCallbackBlock) + (newsize - 1) * sizeof (NRObjectListener)); + g_realloc(object->callbacks, sizeof(NRObjectCallbackBlock) + (newsize - 1) * sizeof (NRObjectListener)); object->callbacks->size = newsize; } @@ -293,7 +294,7 @@ void nr_active_object_remove_listener_by_data(NRActiveObject *object, void *data if ( listener->data == data ) { object->callbacks->length -= 1; if ( object->callbacks->length < 1 ) { - free(object->callbacks); + g_free(object->callbacks); object->callbacks = NULL; } else if ( object->callbacks->length != i ) { *listener = object->callbacks->listeners[object->callbacks->length]; diff --git a/src/libnr/nr-path.cpp b/src/libnr/nr-path.cpp index 6ce2f5f99..99adcb3e1 100644 --- a/src/libnr/nr-path.cpp +++ b/src/libnr/nr-path.cpp @@ -9,6 +9,7 @@ * This code is in public domain */ +#include #include "n-art-bpath.h" #include "nr-rect.h" #include "nr-path.h" @@ -31,7 +32,7 @@ NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NRMatrix const *tra i = 0; while (s->path[i].code != NR_END) i += 1; - d->path = nr_new (NArtBpath, i + 1); + d->path = g_new (NArtBpath, i + 1); i = 0; while (s->path[i].code != NR_END) { diff --git a/src/libnr/nr-pixblock-pattern.cpp b/src/libnr/nr-pixblock-pattern.cpp index 03bd688ba..b4e25638f 100644 --- a/src/libnr/nr-pixblock-pattern.cpp +++ b/src/libnr/nr-pixblock-pattern.cpp @@ -10,6 +10,7 @@ */ +#include #include "nr-pixops.h" #include "nr-pixblock-pattern.h" @@ -34,7 +35,7 @@ nr_pixblock_render_gray_noise (NRPixBlock *pb, NRPixBlock *mask) if (!noise) { int i; - noise = nr_new (unsigned char, NR_NOISE_SIZE); + noise = g_new (unsigned char, NR_NOISE_SIZE); for (i = 0; i < NR_NOISE_SIZE; i++) noise[i] = (rand () / (RAND_MAX >> 8)) & 0xff; } diff --git a/src/libnr/nr-pixblock.cpp b/src/libnr/nr-pixblock.cpp index 59e64b558..079bca6ca 100644 --- a/src/libnr/nr-pixblock.cpp +++ b/src/libnr/nr-pixblock.cpp @@ -9,6 +9,7 @@ * This code is in the Public Domain */ +#include #include "nr-pixblock.h" /// Size of buffer that needs no allocation (default 4). @@ -58,7 +59,7 @@ nr_pixblock_setup_fast (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, i pb->data.px = nr_pixelstore_1M_new (clear, 0x0); } else { pb->size = NR_PIXBLOCK_SIZE_BIG; - pb->data.px = nr_new (unsigned char, size); + pb->data.px = g_new (unsigned char, size); if (clear) memset (pb->data.px, 0x0, size); } @@ -72,7 +73,7 @@ nr_pixblock_setup_fast (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, i } /** - * Pixbuf initialisation using nr_new. + * Pixbuf initialisation using g_new. * * After allocating memory, the buffer is cleared if the clear flag is set. * \param pb Pointer to the pixbuf struct. @@ -97,7 +98,7 @@ nr_pixblock_setup (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1 if (clear) memset (pb->data.p, 0x0, size); } else { pb->size = NR_PIXBLOCK_SIZE_BIG; - pb->data.px = nr_new (unsigned char, size); + pb->data.px = g_new (unsigned char, size); if (clear) memset (pb->data.px, 0x0, size); } @@ -183,7 +184,7 @@ nr_pixblock_release (NRPixBlock *pb) nr_pixelstore_1M_free (pb->data.px); break; case NR_PIXBLOCK_SIZE_BIG: - nr_free (pb->data.px); + g_free (pb->data.px); break; case NR_PIXBLOCK_SIZE_STATIC: break; @@ -196,14 +197,14 @@ nr_pixblock_release (NRPixBlock *pb) * Allocates NRPixBlock and sets it up. * * \return Pointer to fresh pixblock. - * Calls nr_new() and nr_pixblock_setup(). + * Calls g_new() and nr_pixblock_setup(). */ NRPixBlock * nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear) { NRPixBlock *pb; - pb = nr_new (NRPixBlock, 1); + pb = g_new (NRPixBlock, 1); nr_pixblock_setup (pb, mode, x0, y0, x1, y1, clear); @@ -220,7 +221,7 @@ nr_pixblock_free (NRPixBlock *pb) { nr_pixblock_release (pb); - nr_free (pb); + g_free (pb); return NULL; } @@ -241,7 +242,7 @@ nr_pixelstore_4K_new (bool clear, unsigned char val) nr_4K_len -= 1; px = nr_4K_px[nr_4K_len]; } else { - px = nr_new (unsigned char, 4096); + px = g_new (unsigned char, 4096); } if (clear) memset (px, val, 4096); @@ -254,7 +255,7 @@ nr_pixelstore_4K_free (unsigned char *px) { if (nr_4K_len == nr_4K_size) { nr_4K_size += NR_4K_BLOCK; - nr_4K_px = nr_renew (nr_4K_px, unsigned char *, nr_4K_size); + nr_4K_px = g_renew (unsigned char *, nr_4K_px, nr_4K_size); } nr_4K_px[nr_4K_len] = px; @@ -275,7 +276,7 @@ nr_pixelstore_16K_new (bool clear, unsigned char val) nr_16K_len -= 1; px = nr_16K_px[nr_16K_len]; } else { - px = nr_new (unsigned char, 16384); + px = g_new (unsigned char, 16384); } if (clear) memset (px, val, 16384); @@ -288,7 +289,7 @@ nr_pixelstore_16K_free (unsigned char *px) { if (nr_16K_len == nr_16K_size) { nr_16K_size += NR_16K_BLOCK; - nr_16K_px = nr_renew (nr_16K_px, unsigned char *, nr_16K_size); + nr_16K_px = g_renew (unsigned char *, nr_16K_px, nr_16K_size); } nr_16K_px[nr_16K_len] = px; @@ -309,7 +310,7 @@ nr_pixelstore_64K_new (bool clear, unsigned char val) nr_64K_len -= 1; px = nr_64K_px[nr_64K_len]; } else { - px = nr_new (unsigned char, 65536); + px = g_new (unsigned char, 65536); } if (clear) memset (px, val, 65536); @@ -322,7 +323,7 @@ nr_pixelstore_64K_free (unsigned char *px) { if (nr_64K_len == nr_64K_size) { nr_64K_size += NR_64K_BLOCK; - nr_64K_px = nr_renew (nr_64K_px, unsigned char *, nr_64K_size); + nr_64K_px = g_renew (unsigned char *, nr_64K_px, nr_64K_size); } nr_64K_px[nr_64K_len] = px; @@ -344,7 +345,7 @@ nr_pixelstore_256K_new (bool clear, unsigned char val) nr_256K_len -= 1; px = nr_256K_px[nr_256K_len]; } else { - px = nr_new (unsigned char, NR_256K); + px = g_new (unsigned char, NR_256K); } if (clear) memset (px, val, NR_256K); @@ -357,7 +358,7 @@ nr_pixelstore_256K_free (unsigned char *px) { if (nr_256K_len == nr_256K_size) { nr_256K_size += NR_256K_BLOCK; - nr_256K_px = nr_renew (nr_256K_px, unsigned char *, nr_256K_size); + nr_256K_px = g_renew (unsigned char *, nr_256K_px, nr_256K_size); } nr_256K_px[nr_256K_len] = px; @@ -379,7 +380,7 @@ nr_pixelstore_1M_new (bool clear, unsigned char val) nr_1M_len -= 1; px = nr_1M_px[nr_1M_len]; } else { - px = nr_new (unsigned char, NR_1M); + px = g_new (unsigned char, NR_1M); } if (clear) memset (px, val, NR_1M); @@ -392,7 +393,7 @@ nr_pixelstore_1M_free (unsigned char *px) { if (nr_1M_len == nr_1M_size) { nr_1M_size += NR_1M_BLOCK; - nr_1M_px = nr_renew (nr_1M_px, unsigned char *, nr_1M_size); + nr_1M_px = g_renew (unsigned char *, nr_1M_px, nr_1M_size); } nr_1M_px[nr_1M_len] = px; diff --git a/src/libnr/nr-svp-render.cpp b/src/libnr/nr-svp-render.cpp index 0c3b391d5..0ca73bc0e 100644 --- a/src/libnr/nr-svp-render.cpp +++ b/src/libnr/nr-svp-render.cpp @@ -14,6 +14,7 @@ #define noNR_VERBOSE +#include #include "nr-svp-render.h" static void nr_svp_render (NRSVP *svp, unsigned char *px, unsigned int bpp, unsigned int rs, int x0, int y0, int x1, int y1, @@ -371,7 +372,7 @@ nr_slice_new (int wind, NRPoint *points, unsigned int length, NR::Coord y) if (s == NULL) { int i; - s = nr_new (NRSlice, NR_SLICE_ALLOC_SIZE); + s = g_new (NRSlice, NR_SLICE_ALLOC_SIZE); for (i = 1; i < (NR_SLICE_ALLOC_SIZE - 1); i++) s[i].next = &s[i + 1]; s[NR_SLICE_ALLOC_SIZE - 1].next = NULL; ffslice = s + 1; @@ -521,7 +522,7 @@ nr_run_new (NR::Coord x0, NR::Coord y0, NR::Coord x1, NR::Coord y1, int wind) if (r == NULL) { int i; - r = nr_new (NRRun, NR_RUN_ALLOC_SIZE); + r = g_new (NRRun, NR_RUN_ALLOC_SIZE); for (i = 1; i < (NR_RUN_ALLOC_SIZE - 1); i++) (r + i)->next = (r + i + 1); (r + NR_RUN_ALLOC_SIZE - 1)->next = NULL; ffrun = r + 1; diff --git a/src/libnr/nr-svp.cpp b/src/libnr/nr-svp.cpp index a1484397a..7fa2cfd36 100644 --- a/src/libnr/nr-svp.cpp +++ b/src/libnr/nr-svp.cpp @@ -21,6 +21,7 @@ # include #endif +#include #include "nr-rect.h" #include "nr-svp-private.h" @@ -29,7 +30,7 @@ void nr_svp_free (NRSVP *svp) { - if (svp->points) nr_free (svp->points); + if (svp->points) g_free (svp->points); free (svp); } @@ -83,7 +84,7 @@ nr_vertex_new (void) if (v == NULL) { int i; - v = nr_new (NRVertex, NR_VERTEX_ALLOC_SIZE); + v = g_new (NRVertex, NR_VERTEX_ALLOC_SIZE); for (i = 1; i < (NR_VERTEX_ALLOC_SIZE - 1); i++) v[i].next = &v[i + 1]; v[NR_VERTEX_ALLOC_SIZE - 1].next = NULL; ffvertex = v + 1; @@ -91,7 +92,7 @@ nr_vertex_new (void) ffvertex = v->next; } #else - v = nr_new (NRVertex, 1); + v = g_new (NRVertex, 1); #endif v->next = NULL; @@ -127,7 +128,7 @@ nr_vertex_free_one (NRVertex * v) v->next = ffvertex; ffvertex = v; #else - nr_free (v); + g_free (v); #endif } @@ -144,7 +145,7 @@ nr_vertex_free_list (NRVertex * v) l = v; while (l) { n = l->next; - nr_free (l); + g_free (l); l = n; } #endif diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 5fc7e0b3b..b55dc50c2 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -16,6 +16,7 @@ # include "config.h" #endif +#include #include // _() /* Freetype2 */ @@ -237,17 +238,17 @@ style_record_compare(void const *aa, void const *bb) static void font_factory_name_list_destructor(NRNameList *list) { for (unsigned int i = 0; i < list->length; i++) - free(list->names[i]); - if ( list->names ) nr_free(list->names); + g_free(list->names[i]); + if ( list->names ) g_free(list->names); } static void font_factory_style_list_destructor(NRStyleList *list) { for (unsigned int i = 0; i < list->length; i++) { - free((void *) (list->records)[i].name); - free((void *) (list->records)[i].descr); + g_free((void *) (list->records)[i].name); + g_free((void *) (list->records)[i].descr); } - if ( list->records ) nr_free(list->records); + if ( list->records ) g_free(list->records); } /** @@ -295,7 +296,7 @@ font_factory::font_factory(void) fontSize = 512; nbEnt = 0; maxEnt = 32; - ents = (font_entry*)malloc(maxEnt*sizeof(font_entry)); + ents = (font_entry*)g_malloc(maxEnt*sizeof(font_entry)); #ifdef USE_PANGO_WIN32 hScreenDC = pango_win32_get_dc(); @@ -313,7 +314,7 @@ font_factory::font_factory(void) font_factory::~font_factory(void) { for (int i = 0;i < nbEnt;i++) ents[i].f->Unref(); - if ( ents ) free(ents); + if ( ents ) g_free(ents); g_object_unref(fontServer); #ifdef USE_PANGO_WIN32 @@ -375,7 +376,7 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) if ( canFail ) { char *tc = pango_font_description_to_string(descr); PANGO_DEBUG("falling back from %s to Sans because InstallFace failed\n",tc); - free(tc); + g_free(tc); pango_font_description_set_family(descr,"Sans"); res = Face(descr,false); } @@ -477,7 +478,7 @@ void font_factory::UnrefFace(font_instance *who) // not found char *tc = pango_font_description_to_string(who->descr); g_warning("unrefFace %p=%s: failed\n",who,tc); - free(tc); + g_free(tc); } else { loadedFaces.erase(loadedFaces.find(who->descr)); // printf("unrefFace %p: success\n",who); @@ -493,7 +494,7 @@ NRNameList *font_factory::Families(NRNameList *flist) PANGO_DEBUG("got %d families\n", nbFam); flist->length = nbFam; - flist->names = (guchar **)malloc(nbFam*sizeof(guchar*)); + flist->names = (guchar **)g_malloc(nbFam*sizeof(guchar*)); flist->destructor = font_factory_name_list_destructor; for (int i = 0;i < nbFam;i++) { @@ -545,7 +546,7 @@ NRStyleList *font_factory::Styles(gchar const *family, NRStyleList *slist) int nFaces = 0; pango_font_family_list_faces(theFam, &faces, &nFaces); - slist->records = (NRStyleRecord *) malloc(nFaces * sizeof(NRStyleRecord)); + slist->records = (NRStyleRecord *) g_malloc(nFaces * sizeof(NRStyleRecord)); slist->destructor = font_factory_style_list_destructor; int nr = 0; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index bdcc6cf3f..40bd71027 100755 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -8,6 +8,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include "Layout-TNG.h" #include "display/nr-arena-glyphs.h" #include "style.h" @@ -145,7 +146,7 @@ void Layout::print(SPPrintContext *ctx, sp_print_fill(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox); if (text_source->style->stroke.type != SP_PAINT_TYPE_NONE) sp_print_stroke(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox); - nr_free(abp.path); + g_free(abp.path); } glyph_index++; } else { diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp index 616134383..34b1e43b8 100644 --- a/src/libnrtype/nr-type-primitives.cpp +++ b/src/libnrtype/nr-type-primitives.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include "nr-type-primitives.h" @@ -65,10 +66,10 @@ nr_type_dict_new (void) NRTypeDict *td; int i; - td = nr_new (NRTypeDict, 1); + td = g_new (NRTypeDict, 1); td->size = NR_DICTSIZE; - td->entries = nr_new (NRTDEntry *, td->size); + td->entries = g_new (NRTDEntry *, td->size); for (i = 0; i < NR_DICTSIZE; i++) { td->entries[i] = NULL; } @@ -152,7 +153,7 @@ nr_td_entry_new (void) if (!nr_tde_free_list) { int i; - nr_tde_free_list = nr_new (NRTDEntry, NR_TDE_BLOCK_SIZE); + nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE); for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) { nr_tde_free_list[i].next = nr_tde_free_list + i + 1; } diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index c11754ece..ba181476f 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -19,6 +19,7 @@ #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" +#include #include #include "sp-path.h" #include "sp-text.h" @@ -98,7 +99,7 @@ sp_selected_path_combine(void) NArtBpath *abp = nr_artpath_affine(SP_CURVE_BPATH(c), SP_ITEM(path)->transform); sp_curve_unref(c); gchar *str = sp_svg_write_path(abp); - nr_free(abp); + g_free(abp); dstring = g_string_append(dstring, str); g_free(str); diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 0b4d954bf..5a5a9fc6b 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -541,7 +541,7 @@ sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) view = NULL; } if (!view) { - view = (SPMarkerView *)malloc (sizeof (SPMarkerView) + (size) * sizeof (NRArenaItem *)); + view = (SPMarkerView *)g_malloc (sizeof (SPMarkerView) + (size) * sizeof (NRArenaItem *)); for (i = 0; i < size; i++) view->items[i] = NULL; view->next = marker->views; marker->views = view; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 057ebac5a..ed7e34147 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -18,6 +18,7 @@ #endif #include +#include #include "xml/repr.h" #include "svg/svg.h" #include "sp-path.h" @@ -1653,7 +1654,7 @@ Path_for_item(SPItem *item, bool doTransformation, bool transformFull) } if ( doTransformation ) { - if ( bpath ) nr_free(bpath); + if ( bpath ) g_free(bpath); } else { sp_curve_unref(curve); } diff --git a/src/ui/widget/icon-widget.cpp b/src/ui/widget/icon-widget.cpp index c456778b6..7e812236f 100644 --- a/src/ui/widget/icon-widget.cpp +++ b/src/ui/widget/icon-widget.cpp @@ -14,6 +14,7 @@ # include #endif +#include #include "icon-widget.h" namespace Inkscape { @@ -49,7 +50,7 @@ IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) /* TODO _pb = gdk_pixbuf_new_from_data(pixels, GDK_COLORSPACE_RGB, TRUE, 8, _size, _size, _size * 4, - (GdkPixbufDestroyNotify)nr_free, NULL); + (GdkPixbufDestroyNotify)g_free, NULL); */ } } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 0aa01a37e..264349bd1 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -18,6 +18,7 @@ +#include #include #include #include @@ -209,12 +210,12 @@ void sp_icon_fetch_pixbuf( SPIcon *icon ) pixels = sp_icon_image_load( icon, icon->name ); if (pixels) { - // don't pass the nr_free because we're caching the pixel + // don't pass the g_free because we're caching the pixel // space loaded through ... // I just changed this. make sure sp_icon_image_load still does the right thing. icon->pb = gdk_pixbuf_new_from_data(pixels, GDK_COLORSPACE_RGB, TRUE, 8, icon->psize, icon->psize, icon->psize * 4, - /*(GdkPixbufDestroyNotify)nr_free*/NULL, NULL); + /*(GdkPixbufDestroyNotify)g_free*/NULL, NULL); icon->pb_faded = gdk_pixbuf_copy(icon->pb); pixels = gdk_pixbuf_get_pixels(icon->pb_faded); @@ -583,7 +584,7 @@ sp_icon_image_load_pixmap(gchar const *name, unsigned lsize, unsigned psize) } guchar *spx = gdk_pixbuf_get_pixels(pb); int srs = gdk_pixbuf_get_rowstride(pb); - px = nr_new(guchar, 4 * psize * psize); + px = g_new(guchar, 4 * psize * psize); for (unsigned y = 0; y < psize; y++) { memcpy(px + 4 * y * psize, spx + y * srs, 4 * psize); } @@ -703,7 +704,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.x0, (double)ua.y0, (double)ua.x1, (double)ua.y1 ); } /* Set up pixblock */ - px = nr_new(guchar, 4 * psize * psize); + px = g_new(guchar, 4 * psize * psize); memset(px, 0x00, 4 * psize * psize); /* Render */ NRPixBlock B; -- 2.30.2