Improvement of ft_ansi_stream_io

View: New views
4 Messages — Rating Filter:   Alert me  

Parent Message unknown Improvement of ft_ansi_stream_io

by Werner LEMBERG :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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
Freetype-devel@...
http://lists.nongnu.org/mailman/listinfo/freetype-devel

Re: Improvement of ft_ansi_stream_io

by Werner LEMBERG :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


My request again for review...


    Werner


> 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
Freetype-devel@...
http://lists.nongnu.org/mailman/listinfo/freetype-devel

Re: Improvement of ft_ansi_stream_io

by David Turner-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Looks fine to me

- David

2009/6/19 Werner LEMBERG <wl@...>

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
Freetype-devel@...
http://lists.nongnu.org/mailman/listinfo/freetype-devel


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

Re: Improvement of ft_ansi_stream_io

by Werner LEMBERG :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Looks fine to me

Applied, thanks.


    Werner


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