9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] stringwidth leak or ignorance?
@ 2005-05-26 10:32 Fco. J. Ballesteros
  2005-05-28  8:18 ` Rob Pike
  0 siblings, 1 reply; 2+ messages in thread
From: Fco. J. Ballesteros @ 2005-05-26 10:32 UTC (permalink / raw)
  To: 9fans


Hi,

	I've seen that  at point 
sys/src/libdraw/stringwidth.c:46
  45		if(subfontname){
>46			if(_getsubfont(f->display, subfontname) == 0){
 47				def = f->display->defaultfont;
 48				if(def && f!=def)
 49					f = def;
 50				else
 51					break;

there seems to be a leak.
_getsubfont returns a Subfont, which is not freed. However, there
seems to be some side effect, because if I free the subfont, the routine breaks.

This came from using leak on a program using stringwidth a lot. The program
shows leaks that come from this point. So I tried to fix it. I still don't know enough
of font handling to propose a course of action. Any suggestion?

If I come up with a fix, I'll send a patch anyway.

thanks



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] stringwidth leak or ignorance?
  2005-05-26 10:32 [9fans] stringwidth leak or ignorance? Fco. J. Ballesteros
@ 2005-05-28  8:18 ` Rob Pike
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Pike @ 2005-05-28  8:18 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

the call to _getsubfont just puts the subfont into the subfont
cache so the character can be looked up there the next time
around the loop.  there should be no leak.  freeing the subfont
will break the cache.

-rob

On 5/26/05, Fco. J. Ballesteros <nemo@lsub.org> wrote:
> 
> Hi,
> 
>         I've seen that  at point
> sys/src/libdraw/stringwidth.c:46
>   45            if(subfontname){
> >46                     if(_getsubfont(f->display, subfontname) == 0){
>  47                             def = f->display->defaultfont;
>  48                             if(def && f!=def)
>  49                                     f = def;
>  50                             else
>  51                                     break;
> 
> there seems to be a leak.
> _getsubfont returns a Subfont, which is not freed. However, there
> seems to be some side effect, because if I free the subfont, the routine breaks.
> 
> This came from using leak on a program using stringwidth a lot. The program
> shows leaks that come from this point. So I tried to fix it. I still don't know enough
> of font handling to propose a course of action. Any suggestion?
> 
> If I come up with a fix, I'll send a patch anyway.
> 
> thanks
> 
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-28  8:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-26 10:32 [9fans] stringwidth leak or ignorance? Fco. J. Ballesteros
2005-05-28  8:18 ` Rob Pike

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 NNTP newsgroup(s).