about summary refs log tree commit diff
path: root/libio/fmemopen.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-03-04 00:49:46 -0500
committerUlrich Drepper <drepper@gmail.com>2011-03-04 00:49:46 -0500
commit13a804de8f3091e8ccd9b650f61becd6e1304227 (patch)
tree1729ce30bbb6ddec3352371437d8f939a1d572bc /libio/fmemopen.c
parent9d25c392ba73065ac20f518d1cef1cdc96860545 (diff)
downloadglibc-13a804de8f3091e8ccd9b650f61becd6e1304227.tar.gz
glibc-13a804de8f3091e8ccd9b650f61becd6e1304227.tar.xz
glibc-13a804de8f3091e8ccd9b650f61becd6e1304227.zip
Optimize fmemopen a bit.
Diffstat (limited to 'libio/fmemopen.c')
-rw-r--r--libio/fmemopen.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c
index 1a631d5122..75f9f7e5f6 100644
--- a/libio/fmemopen.c
+++ b/libio/fmemopen.c
@@ -226,6 +226,7 @@ fmemopen (void *buf, size_t len, const char *mode)
 	  return NULL;
 	}
       c->buffer[0] = '\0';
+      c->maxpos = 0;
     }
   else
     {
@@ -236,14 +237,14 @@ fmemopen (void *buf, size_t len, const char *mode)
 	}
 
       c->buffer = buf;
-    }
 
-  c->size = len;
+      if (mode[0] == 'w')
+	c->buffer[0] = '\0';
 
-  if (mode[0] == 'w')
-    c->buffer[0] = '\0';
+      c->maxpos = strnlen (c->buffer, len);
+    }
 
-  c->maxpos = strnlen (c->buffer, len);
+  c->size = len;
 
   if (mode[0] == 'a')
     c->pos = c->maxpos;