[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] Improvement of ft_ansi_stream_io
From: |
Werner LEMBERG |
Subject: |
Re: [ft-devel] Improvement of ft_ansi_stream_io |
Date: |
Wed, 15 Jul 2009 08:12:32 +0200 (CEST) |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [ft-devel] Improvement of ft_ansi_stream_io,
Werner LEMBERG <=