tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] [PATCH] tcc.h (BufferedFile): Remove unnecessary stat


From: David Mertens
Subject: Re: [Tinycc-devel] [PATCH] tcc.h (BufferedFile): Remove unnecessary static memory allocation
Date: Thu, 18 Dec 2014 20:04:50 -0500

I agree with your interpretation, and fix. For reference, tcc_open_bf is defined in libtcc.c. The two applicable lines are:

int buflen = initlen ? initlen : IO_BUF_SIZE;
bf = tcc_malloc(sizeof(BufferedFile) + buflen);

As presently defined, BufferedFile indicates that its last field is a string with size IO_BUF_SIZE. But this way of allocating things looks like it's allocating a struct with a flexible last field, so its size should be 1.

If you apply your patch, do the tests pass?

David

On Mon, Dec 15, 2014 at 3:44 AM, Lee Duhem <address@hidden> wrote:
Hi,

The memory needed by `buffer' will be allocated in `tcc_open_bf',
these is no need to allocate them in BufferedFile statically.

Any comment?

lee

_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel



--
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

reply via email to

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