OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[linuxjm/LDP_man-pages.git] / original / man3 / fopencookie.3
index e20ad44..ed371a3 100644 (file)
@@ -1,6 +1,7 @@
 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
 .\"      <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
@@ -20,6 +21,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .TH FOPENCOOKIE 3 2012-04-30 "Linux" "Linux Programmer's Manual"
 .SH NAME
@@ -293,8 +295,8 @@ memfile_write(void *c, const char *buf, size_t size)
 
     /* Buffer too small? Keep doubling size until big enough */
 
-    while (size + cookie\->offset > cookie->allocated) {
-        new_buff = realloc(cookie\->buf, cookie->allocated * 2);
+    while (size + cookie\->offset > cookie\->allocated) {
+        new_buff = realloc(cookie\->buf, cookie\->allocated * 2);
         if (new_buff == NULL) {
             return \-1;
         } else {
@@ -303,11 +305,11 @@ memfile_write(void *c, const char *buf, size_t size)
         }
     }
 
-    memcpy(cookie\->buf + cookie->offset, buf, size);
+    memcpy(cookie\->buf + cookie\->offset, buf, size);
 
     cookie\->offset += size;
-    if (cookie\->offset > cookie->endpos)
-        cookie\->endpos = cookie->offset;
+    if (cookie\->offset > cookie\->endpos)
+        cookie\->endpos = cookie\->offset;
 
     return size;
 }
@@ -321,12 +323,12 @@ memfile_read(void *c, char *buf, size_t size)
     /* Fetch minimum of bytes requested and bytes available */
 
     xbytes = size;
-    if (cookie\->offset + size > cookie->endpos)
-        xbytes = cookie\->endpos - cookie->offset;
+    if (cookie\->offset + size > cookie\->endpos)
+        xbytes = cookie\->endpos \- cookie\->offset;
     if (xbytes < 0)     /* offset may be past endpos */
        xbytes = 0;
 
-    memcpy(buf, cookie\->buf + cookie->offset, xbytes);
+    memcpy(buf, cookie\->buf + cookie\->offset, xbytes);
 
     cookie\->offset += xbytes;
     return xbytes;