summaryrefslogtreecommitdiff
path: root/sql/mf_iocache.cc
diff options
context:
space:
mode:
authormonty@donna.mysql.com <>2000-11-18 02:15:06 +0200
committermonty@donna.mysql.com <>2000-11-18 02:15:06 +0200
commite5dcd8bed327259fa09cfe7e82fc4dbe7642b8bd (patch)
treee47c14103d1588f6a27c229783e07d73438c96d0 /sql/mf_iocache.cc
parent19a9f8f943ad93d0d607ff358cd7314a6ee262d2 (diff)
downloadmariadb-git-e5dcd8bed327259fa09cfe7e82fc4dbe7642b8bd.tar.gz
Portability fixes
Diffstat (limited to 'sql/mf_iocache.cc')
-rw-r--r--sql/mf_iocache.cc21
1 files changed, 13 insertions, 8 deletions
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc
index c1e6b37a848..f723e35ca93 100644
--- a/sql/mf_iocache.cc
+++ b/sql/mf_iocache.cc
@@ -37,6 +37,7 @@
#include <errno.h>
static void my_aiowait(my_aio_result *result);
#endif
+#include <assert.h>
extern "C" {
@@ -233,24 +234,28 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
- /* Read buffered. Returns 1 if can't read requested characters */
- /* Returns 0 if record read */
+ /*
+ Read buffered. Returns 1 if can't read requested characters
+ This function is only called from the my_b_read() macro
+ when there isn't enough characters in the buffer to
+ satisfy the request.
+ Returns 0 we succeeded in reading all data
+ */
int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
{
uint length,diff_length,left_length;
my_off_t max_length, pos_in_file;
- if((left_length=(uint) (info->rc_end-info->rc_pos)))
+ if ((left_length=(uint) (info->rc_end-info->rc_pos)))
{
- if(Count < left_length)
- left_length = Count;
- memcpy(Buffer,info->rc_pos,
- (size_t) (left_length));
+ dbug_assert(Count >= left_length); /* User is not using my_b_read() */
+ memcpy(Buffer,info->rc_pos, (size_t) (left_length));
Buffer+=left_length;
Count-=left_length;
}
- pos_in_file=info->pos_in_file+ left_length;
+ /* pos_in_file always point on where info->buffer was read */
+ pos_in_file=info->pos_in_file+(uint) (info->rc_end - info->buffer);
if (info->seek_not_done)
{ /* File touched, do seek */
VOID(my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)));