mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
Update from gnulib.
This commit is contained in:
1 parent
2f7002a28f
commit
87e53abf55
1 file changed
+5
-8
+5
-8
@@ -35,9 +35,7 @@
|
||||
void
|
||||
initbuffer (struct linebuffer *linebuffer)
|
||||
{
|
||||
linebuffer->length = 0;
|
||||
linebuffer->size = 200;
|
||||
linebuffer->buffer = xmalloc (linebuffer->size);
|
||||
memset (linebuffer, 0, sizeof *linebuffer);
|
||||
}
|
||||
|
||||
/* Read an arbitrarily long line of text from STREAM into LINEBUFFER.
|
||||
@@ -73,9 +71,9 @@ readlinebuffer (struct linebuffer *linebuffer, FILE *stream)
|
||||
}
|
||||
if (p == end)
|
||||
{
|
||||
linebuffer->size *= 2;
|
||||
buffer = xrealloc (buffer, linebuffer->size);
|
||||
p = p - linebuffer->buffer + buffer;
|
||||
size_t oldsize = linebuffer->size;
|
||||
buffer = x2realloc (buffer, &linebuffer->size);
|
||||
p = buffer + oldsize;
|
||||
linebuffer->buffer = buffer;
|
||||
end = buffer + linebuffer->size;
|
||||
}
|
||||
@@ -87,11 +85,10 @@ readlinebuffer (struct linebuffer *linebuffer, FILE *stream)
|
||||
return linebuffer;
|
||||
}
|
||||
|
||||
/* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */
|
||||
/* Free the buffer that was allocated for linebuffer LINEBUFFER. */
|
||||
|
||||
void
|
||||
freebuffer (struct linebuffer *linebuffer)
|
||||
{
|
||||
free (linebuffer->buffer);
|
||||
free (linebuffer);
|
||||
}
|
||||
Reference in new issue
Block a user