From owner-freebsd-hackers Fri Feb 16 9:11:19 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from news.lucky.net (news.lucky.net [193.193.193.102]) by hub.freebsd.org (Postfix) with ESMTP id 3FF7437B65D for ; Fri, 16 Feb 2001 09:11:12 -0800 (PST) Received: (from mail@localhost) by news.lucky.net (8.Who.Cares/8.Who.Cares) id TEG24599 for freebsd-hackers@freebsd.org; Fri, 16 Feb 2001 19:11:04 +0200 (envelope-from news@news.ntu-kpi.kiev.ua) From: "Andrey Simonenko" To: freebsd-hackers@freebsd.org Subject: Staticaly allocated buffers in library. Is it correct? Date: Fri, 16 Feb 2001 19:07:54 +0300 Organization: NTUU "KPI" Message-ID: <96jmr3$kd7$1@igloo.uran.net.ua> X-Trace: igloo.uran.net.ua 982343331 20903 10.18.54.109 (16 Feb 2001 17:08:51 GMT) X-Complaints-To: newsmaster@news.ntu-kpi.kiev.ua X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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