bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] linebuffer.c bug


From: Simon Josefsson
Subject: [Bug-gnulib] linebuffer.c bug
Date: Wed, 24 Sep 2003 00:02:20 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Should the 'struct linebuffer *' be allocated by the application or by
linebuffer.c?  Right now the code free the pointer, but it never
allocate it, which seems like a bad idea.

Also, it may be good to document that readlinebuffer() never return
anything other than NULL or the input linebuffer parameter, since this
can simply the application code (i.e., 'while (readlinebuffer (lb,
fh))' instead of 'while ((lb = readlinebuffer (lb, fh)))').

void
initbuffer (struct linebuffer *linebuffer)
{
  linebuffer->length = 0;
  linebuffer->size = 200;
  linebuffer->buffer = xmalloc (linebuffer->size);
}

...

void
freebuffer (struct linebuffer *linebuffer)
{
  free (linebuffer->buffer);
  free (linebuffer);
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]