Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Feb 2001 19:07:54 +0300
From:      "Andrey Simonenko" <simon@comsys.ntu-kpi.kiev.ua>
To:        freebsd-hackers@freebsd.org
Subject:   Staticaly allocated buffers in library. Is it correct?
Message-ID:  <96jmr3$kd7$1@igloo.uran.net.ua>

next in thread | raw e-mail | index | archive | help
I patched some library files and noted that some functions, which parse some
configuration files, use staticaly allocated buffers. Sizes of such
staticaly allocated buffers are 8k, 10k and so on. These buffers are used to
hold one line from parsed file. Usually it is enough for one line, but
really this is error (I think).

So, here is my question. Is it a tradition of library functions to use
statically allocated buffers for parsing configuration files? I made my
patch (for my purpose) and additionally remove code with staticaly allocated
buffers and add code with malloc()+realloc() implementation. I think that
one malloc() call which allocates 1k will be enough to hold one line of a
configuration file, but if it is not enough I call realloc() and reallocates
buffer to bigger size.

What do you think about my question?

ps: I understand that I can use buffer with max size equal to max value of
int, unsigned int,  size_t, etc.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?96jmr3$kd7$1>