Skip to content

Commit

Permalink
Optimize fmemopen a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Mar 4, 2011
1 parent 9d25c39 commit 13a804d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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>

* libio/fmemopen.c (fmemopen): Don't read past end of buffer.
Expand Down
11 changes: 6 additions & 5 deletions libio/fmemopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ fmemopen (void *buf, size_t len, const char *mode)
return NULL;
}
c->buffer[0] = '\0';
c->maxpos = 0;
}
else
{
Expand All @@ -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;
Expand Down

0 comments on commit 13a804d

Please sign in to comment.