From: Ulrich Drepper Date: Fri, 4 Mar 2011 05:49:46 +0000 (-0500) Subject: Optimize fmemopen a bit. X-Git-Tag: glibc-2.14~218 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13a804de8f3091e8ccd9b650f61becd6e1304227;p=platform%2Fupstream%2Fglibc.git Optimize fmemopen a bit. --- diff --git a/ChangeLog b/ChangeLog index 16da2c1..c6d652d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-04 Ulrich Drepper + + * libio/fmemopen.c (fmemopen): Optimize a bit. + 2011-03-03 Andreas Schwab * libio/fmemopen.c (fmemopen): Don't read past end of buffer. diff --git a/libio/fmemopen.c b/libio/fmemopen.c index 1a631d5..75f9f7e 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;