freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] patch, allow custom streams to delete themselves


From: Danny
Subject: [Devel] patch, allow custom streams to delete themselves
Date: Tue, 25 May 2004 03:38:12 -0700 (PDT)

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/ 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]