From: Paul Eggert <eggert@cs.ucla.edu>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: trunk r113947: * image.c: Fix animation cache signature memory leak.
Date: Mon, 19 Aug 2013 09:56:23 -0700 [thread overview]
Message-ID: <52124E37.2080709@cs.ucla.edu> (raw)
In-Reply-To: <m3d2p9prbo.fsf@stories.gnus.org>
Lars Magne Ingebrigtsen wrote:
> Or am I misreading this completely?
No, you got it right. I expect that I ran the wrong
executable when I thought I was testing the new code.
My code should have looked like the following, I expect.
The advantage of doing it this way is that it calls
imagemagick_create_cache in just one place, and strcmp
in just one place, and refers to 'animation_cache' in
just one place, and updates cache->update time in just
one place, and overall (to my mind anyway) is easier to
understand than the duplications in the current code.
But it's only a minor improvement.
static struct animation_cache *
imagemagick_get_animation_cache (MagickWand *wand)
{
char *signature = MagickGetImageSignature (wand);
struct animation_cache **pcache = &animation_cache;
imagemagick_prune_animation_cache ();
while (1)
{
struct animation_cache *cache = *pcache;
if (! cache)
{
*pcache = cache = imagemagick_create_cache (signature);
break;
}
if (strcmp (signature, cache->signature) == 0)
{
DestroyString (signature);
break;
}
pcache = &cache->next;
}
cache->update_time = current_emacs_time ();
return cache;
}
By the way, did you know that each animation signature
contains 4 KiB of wasted memory? It's ImageMagick
code that's wasting it. Dunno if that's worth tuning.
next prev parent reply other threads:[~2013-08-19 16:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1VBJTG-0003rv-7A@vcs.savannah.gnu.org>
2013-08-19 15:22 ` trunk r113947: * image.c: Fix animation cache signature memory leak Lars Magne Ingebrigtsen
2013-08-19 16:16 ` Paul Eggert
2013-08-19 16:19 ` Lars Magne Ingebrigtsen
2013-08-19 16:24 ` Paul Eggert
2013-08-19 16:40 ` Lars Magne Ingebrigtsen
2013-08-19 16:56 ` Paul Eggert [this message]
2013-08-19 17:04 ` Lars Magne Ingebrigtsen
2013-08-19 19:46 ` Paul Eggert
2013-08-19 19:51 ` Lars Magne Ingebrigtsen
2013-08-19 20:52 ` Paul Eggert
2013-08-19 20:56 ` Lars Magne Ingebrigtsen
2013-08-19 20:55 ` Lars Magne Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52124E37.2080709@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).