mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Optimize fmemopen a bit.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2011-03-04 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
* libio/fmemopen.c (fmemopen): Optimize a bit.
|
||||||
|
|
||||||
2011-03-03 Andreas Schwab <schwab@redhat.com>
|
2011-03-03 Andreas Schwab <schwab@redhat.com>
|
||||||
|
|
||||||
* libio/fmemopen.c (fmemopen): Don't read past end of buffer.
|
* libio/fmemopen.c (fmemopen): Don't read past end of buffer.
|
||||||
|
@ -226,6 +226,7 @@ fmemopen (void *buf, size_t len, const char *mode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
c->buffer[0] = '\0';
|
c->buffer[0] = '\0';
|
||||||
|
c->maxpos = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -236,15 +237,15 @@ fmemopen (void *buf, size_t len, const char *mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
c->buffer = buf;
|
c->buffer = buf;
|
||||||
|
|
||||||
|
if (mode[0] == 'w')
|
||||||
|
c->buffer[0] = '\0';
|
||||||
|
|
||||||
|
c->maxpos = strnlen (c->buffer, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
c->size = len;
|
c->size = len;
|
||||||
|
|
||||||
if (mode[0] == 'w')
|
|
||||||
c->buffer[0] = '\0';
|
|
||||||
|
|
||||||
c->maxpos = strnlen (c->buffer, len);
|
|
||||||
|
|
||||||
if (mode[0] == 'a')
|
if (mode[0] == 'a')
|
||||||
c->pos = c->maxpos;
|
c->pos = c->maxpos;
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user