freetype-devel
[Top][All Lists]
Advanced

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

Re: [ft-devel] Improvement of ft_ansi_stream_io


From: David Turner
Subject: Re: [ft-devel] Improvement of ft_ansi_stream_io
Date: Mon, 3 Aug 2009 16:30:35 +0200

Looks fine to me

- David

2009/6/19 Werner LEMBERG <address@hidden>

I got the following:

> There is not need to call ft_fseek() every time when execute
> ft_fread().  Here is the patch:
>
> ftsystem.c:
>
>   FT_CALLBACK_DEF( unsigned long )
>   ft_ansi_stream_io( FT_Stream       stream,
>                      unsigned long   offset,
>                      unsigned char*  buffer,
>                      unsigned long   count )
>   {
>     FT_FILE*  file;
>     file = STREAM_FILE( stream );
>   +if ( stream->pos != offset )
>     ft_fseek( file, offset, SEEK_SET );
>     return (unsigned long)ft_fread( buffer, 1, count, file );
>   }
>
> ftstream.c:
>
>   FT_BASE_DEF( FT_Error )
>   FT_Stream_Seek( FT_Stream  stream,
>                   FT_ULong   pos )
>   {
>     FT_Error  error = FT_Err_Ok;
>   -stream->pos = pos;
>     if ( stream->read )
>     {
>       if ( stream->read( stream, pos, 0, 0 ) )
>       {
>         FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
>                    pos, stream->size ));
>         error = FT_Err_Invalid_Stream_Operation;
>       }
>     }
>     /* note that seeking to the first position after the file is valid */
>     else if ( pos > stream->size )
>     {
>       FT_ERROR(( "FT_Stream_Seek: invalid i/o; pos = 0x%lx, size = 0x%lx\n",
>                  pos, stream->size ));
>       error = FT_Err_Invalid_Stream_Operation;
>     }
>   +if ( !error )
>   +  stream->pos = pos;
>     return error;
>   }

Can someone please check the validity of this patch?


   Werner


_______________________________________________
Freetype-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/freetype-devel


reply via email to

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