[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetype-devel
Subject:    [Devel] patch, allow custom streams to delete themselves
From:       Danny <dannyboynow () yahoo ! com>
Date:       2004-05-25 10:38:12
Message-ID: 20040525103812.63067.qmail () web40708 ! mail ! yahoo ! com
[Download RAW message or body]

When using custom stream objects it would be nice to
be able to delete the FT_STREAM from within our custom
close function as to decrease the amount of redundant
bookkeeping we do.  If you try to delete it from your
close function the program will crash accessing
invalid memory.  The problem is that the stream->close
function pointer is set to 0 after the stream is
closed so you can't close it twice.  I looked through
the code and I ran some test cases but couldn't get
any cases where this extra test came in useful.  Most
of the time stream is set equal to NULL right after
closing or freed internally anyway.

This little patch makes it possible for you to delete
your custom STREAM when it is closed by removing the
extra assignment and check.  I've been using this fix
since I mentioned the problem to the FreeType (not
devel) mailing list the 16th.

Index: src/base/ftstream.c
===================================================================
RCS file:
/cvs/freetype/freetype2/src/base/ftstream.c,v
retrieving revision 1.44
diff -u -r1.44 ftstream.c
--- ftstream.c	2004/04/16 03:50:55	1.44
+++ ftstream.c	2004/05/25 10:21:53
@@ -48,10 +48,9 @@
   FT_BASE_DEF( void )
   FT_Stream_Close( FT_Stream  stream )
   {
-    if ( stream && stream->close )
+    if ( stream )
     {
       stream->close( stream );
-      stream->close = NULL;
     }
   }
 





	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

_______________________________________________
Devel mailing list
Devel@freetype.org
http://www.freetype.org/mailman/listinfo/devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic