summaryrefslogtreecommitdiff
path: root/plugins/Zlib/gzread.c
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-05-30 17:27:49 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-05-30 17:27:49 +0000
commit88708cffa15662dcd2755fce699112d24a10a087 (patch)
tree55d362220b42a52b52eaef2254f894c9a61fb4fd /plugins/Zlib/gzread.c
parent7fa5563a954339f3feeb156285ef56bfde7cbec8 (diff)
update for zlib & FreeImage
git-svn-id: http://svn.miranda-ng.org/main/trunk@238 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Zlib/gzread.c')
-rw-r--r--plugins/Zlib/gzread.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/Zlib/gzread.c b/plugins/Zlib/gzread.c
index 714b30c746..c0a179437b 100644
--- a/plugins/Zlib/gzread.c
+++ b/plugins/Zlib/gzread.c
@@ -1,5 +1,5 @@
/* gzread.c -- zlib functions for reading gzip files
- * Copyright (C) 2004, 2005, 2010, 2011 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -57,8 +57,13 @@ local int gz_avail(state)
if (state->err != Z_OK && state->err != Z_BUF_ERROR)
return -1;
if (state->eof == 0) {
- if (strm->avail_in)
- memmove(state->in, strm->next_in, strm->avail_in);
+ if (strm->avail_in) { /* copy what's there to the start */
+ unsigned char *p = state->in, *q = strm->next_in;
+ unsigned n = strm->avail_in;
+ do {
+ *p++ = *q++;
+ } while (--n);
+ }
if (gz_load(state, state->in + strm->avail_in,
state->size - strm->avail_in, &got) == -1)
return -1;
@@ -340,7 +345,7 @@ int ZEXPORT gzread(file, buf, len)
/* get more output, looking for header if required */
if (gz_fetch(state) == -1)
return -1;
- continue; /* no progress yet -- go back to memcpy() above */
+ continue; /* no progress yet -- go back to copy above */
/* the copy above assures that we will leave with space in the
output buffer, allowing at least one gzungetc() to succeed */
}
@@ -373,7 +378,8 @@ int ZEXPORT gzread(file, buf, len)
}
/* -- see zlib.h -- */
-int ZEXPORT gzgetc_(file)
+#undef gzgetc
+int ZEXPORT gzgetc(file)
gzFile file;
{
int ret;
@@ -402,12 +408,11 @@ int ZEXPORT gzgetc_(file)
return ret < 1 ? -1 : buf[0];
}
-#undef gzgetc
-int ZEXPORT gzgetc(file)
+int ZEXPORT gzgetc_(file)
gzFile file;
{
- return gzgetc_(file);
-}
+ return gzgetc(file);
+}
/* -- see zlib.h -- */
int ZEXPORT gzungetc(c, file)