[PATCH] ntdll: Increase size of buffer used to read lines of /proc/cpuinfo
jjmckenzie51 at earthlink.net
Fri Nov 26 08:14:31 CST 2010
On 11/25/10 9:56 PM, Vitaliy Margolen wrote:
> On 11/24/2010 07:19 PM, James McKenzie wrote:
>> On 11/24/10 6:56 PM, Vitaliy Margolen wrote:
>>> On 11/24/2010 12:23 PM, jimportal at gmail.com wrote:
>>>> From: James Eder<jimportal at gmail.com>
>>>> - while (fgets(line,200,f) != NULL)
>>>> + while (fgets(line,450,f) != NULL)
>>> You might as well then change this to "sizeof(line)".
>> Just for my edification, is there not a better way then setting the
>> line to a flexible length for this purpose.
> Unless I didn't understand your question - you can't set a buffer to a
> "variable length". You have to provide fgets() a size of the buffer so
> it can read at most that many characters -1 for terminating \0.
Clarification: If we know the length of the input should we not set up
the buffer to that length? If we don't know should we not set it to a
maximum expected length that is a known value within the system?
Pseudo code for known case:
Length = # of characters in existing variable
buffer [Length +1]
Pseudo code for unknown case:
MaxLengthofCharacterString = 1024
Gets away from 'magic numbers' like 250 and 450.
More information about the wine-devel