mirror of https://github.com/GNOME/gimp.git
changed tile_init() to tile_new() and return a GSlice-allocated Tile
2007-05-22 Michael Natterer <mitch@gimp.org> * app/base/tile.[ch]: changed tile_init() to tile_new() and return a GSlice-allocated Tile structure. (tile_destroy): free it using GSLice. * app/base/tile-manager.c: use tile_new() instead of g_new plus tile_init(). Also allocate TileManager itself using GSlice. * app/xcf/xcf-load.c (xcf_load_parasite): allocate parasites using gimp_parasite_new(). svn path=/trunk/; revision=22571
This commit is contained in:
parent
b8fe16c193
commit
7654733de9
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2007-05-22 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/base/tile.[ch]: changed tile_init() to tile_new() and return
|
||||
a GSlice-allocated Tile structure.
|
||||
|
||||
(tile_destroy): free it using GSLice.
|
||||
|
||||
* app/base/tile-manager.c: use tile_new() instead of g_new plus
|
||||
tile_init(). Also allocate TileManager itself using GSlice.
|
||||
|
||||
* app/xcf/xcf-load.c (xcf_load_parasite): allocate parasites using
|
||||
gimp_parasite_new().
|
||||
|
||||
2007-05-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gtkvwrapbox.c
|
||||
|
|
|
@ -55,7 +55,7 @@ tile_manager_new (gint width,
|
|||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||
g_return_val_if_fail (bpp > 0 && bpp <= 4, NULL);
|
||||
|
||||
tm = g_new0 (TileManager, 1);
|
||||
tm = g_slice_new0 (TileManager);
|
||||
|
||||
tm->ref_count = 1;
|
||||
tm->width = width;
|
||||
|
@ -101,7 +101,7 @@ tile_manager_unref (TileManager *tm)
|
|||
g_free (tm->tiles);
|
||||
}
|
||||
|
||||
g_free (tm);
|
||||
g_slice_free (TileManager, tm);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,9 +164,8 @@ tile_manager_get (TileManager *tm,
|
|||
{
|
||||
for (j = 0; j < ncols; j++, k++)
|
||||
{
|
||||
Tile *new = g_new (Tile, 1);
|
||||
Tile *new = tile_new (tm->bpp);
|
||||
|
||||
tile_init (new, tm->bpp);
|
||||
tile_attach (new, tm, k);
|
||||
|
||||
if (j == (ncols - 1))
|
||||
|
@ -200,9 +199,7 @@ tile_manager_get (TileManager *tm,
|
|||
if ((*tile_ptr)->share_count > 1)
|
||||
{
|
||||
/* Copy-on-write required */
|
||||
Tile *new = g_new (Tile, 1);
|
||||
|
||||
tile_init (new, (*tile_ptr)->bpp);
|
||||
Tile *new = tile_new ((*tile_ptr)->bpp);
|
||||
|
||||
new->ewidth = (*tile_ptr)->ewidth;
|
||||
new->eheight = (*tile_ptr)->eheight;
|
||||
|
@ -339,12 +336,10 @@ tile_invalidate (Tile **tile_ptr,
|
|||
if (G_UNLIKELY (tile->share_count > 1))
|
||||
{
|
||||
/* This tile is shared. Replace it with a new, invalid tile. */
|
||||
Tile *new = g_new (Tile, 1);
|
||||
Tile *new = tile_new (tile->bpp);
|
||||
|
||||
g_print ("invalidating shared tile (executing buggy code!!!)\n");
|
||||
|
||||
tile_init (new, tile->bpp);
|
||||
|
||||
new->ewidth = tile->ewidth;
|
||||
new->eheight = tile->eheight;
|
||||
new->size = tile->size;
|
||||
|
@ -438,12 +433,11 @@ tile_manager_map (TileManager *tm,
|
|||
{
|
||||
for (j = 0; j < ncols; j++, k++)
|
||||
{
|
||||
Tile *new = g_new (Tile, 1);
|
||||
Tile *new = tile_new (tm->bpp);
|
||||
|
||||
#ifdef DEBUG_TILE_MANAGER
|
||||
g_printerr (",");
|
||||
#endif
|
||||
tile_init (new, tm->bpp);
|
||||
tile_attach (new, tm, k);
|
||||
|
||||
if (j == (ncols - 1))
|
||||
|
|
|
@ -104,10 +104,11 @@ tile_set_rowhint (Tile *tile,
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
tile_init (Tile *tile,
|
||||
gint bpp)
|
||||
Tile *
|
||||
tile_new (gint bpp)
|
||||
{
|
||||
Tile *tile = g_slice_new (Tile);
|
||||
|
||||
tile->ref_count = 0;
|
||||
tile->write_count = 0;
|
||||
tile->share_count = 0;
|
||||
|
@ -128,6 +129,8 @@ tile_init (Tile *tile,
|
|||
#ifdef TILE_PROFILING
|
||||
tile_count++;
|
||||
#endif
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -269,7 +272,7 @@ tile_destroy (Tile *tile)
|
|||
if (tile->listhead)
|
||||
tile_cache_flush (tile);
|
||||
|
||||
g_free (tile);
|
||||
g_slice_free (Tile, tile);
|
||||
|
||||
#ifdef TILE_PROFILING
|
||||
tile_count--;
|
||||
|
|
|
@ -39,10 +39,9 @@ typedef guchar TileRowHint;
|
|||
#define TILEROWHINT_BROKEN 6
|
||||
|
||||
|
||||
/* Initializes the fields of a tile to "good" values.
|
||||
/* Returns a newly allocated Tile with all fields initialized to "good" values.
|
||||
*/
|
||||
void tile_init (Tile *tile,
|
||||
gint bpp);
|
||||
Tile * tile_new (gint bpp);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -1488,9 +1488,12 @@ static GimpParasite *
|
|||
xcf_load_parasite (XcfInfo *info)
|
||||
{
|
||||
GimpParasite *p;
|
||||
gchar *name;
|
||||
|
||||
info->cp += xcf_read_string (info->fp, &name, 1);
|
||||
p = gimp_parasite_new (name, 0, 0, NULL);
|
||||
g_free (name);
|
||||
|
||||
p = g_new (GimpParasite, 1);
|
||||
info->cp += xcf_read_string (info->fp, &p->name, 1);
|
||||
info->cp += xcf_read_int32 (info->fp, &p->flags, 1);
|
||||
info->cp += xcf_read_int32 (info->fp, &p->size, 1);
|
||||
p->data = g_new (gchar, p->size);
|
||||
|
|
Loading…
Reference in New Issue