On Sat, Sep 06, 2008 at 11:25:19AM +0100, Jonas Maebe wrote:
On 05 Sep 2008, at 17:25, Peter Popov wrote:
In FPC it is done by design. If 0 bytes are asked we allocate at
least the minimum alignment to
get a valid pointer. This is done for compatibility with TP7.0 that
returns the
On Sat, Sep 06, 2008 at 11:25:19AM +0100, Jonas Maebe wrote:
On 05 Sep 2008, at 17:25, Peter Popov wrote:
In FPC it is done by design. If 0 bytes are asked we allocate at
least the minimum alignment to
get a valid pointer. This is done for compatibility with TP7.0 that
returns the value of
On 05 Sep 2008, at 17:25, Peter Popov wrote:
In FPC it is done by design. If 0 bytes are asked we allocate at
least the minimum alignment to
get a valid pointer. This is done for compatibility with TP7.0 that
returns the value of heapptr
which is also a valid pointer.
Thanks for the
Peter Popov wrote:
As I was porting things from delphi to fp today I noticed the
following difference:
Delphi (2,5) : GetMem(p, 0) will set p to nil.
FPC (2.2.2, 2.3.1) : GetMem(p, 0) will assign something to p
Should it be forbidden do allocate a buffer of size 0 and reallocate it
Peter Popov wrote:
Well, if it points to something, then there is space, isn't it? Unless
it is clearly mentioned in the documentation that GetMem(p,0) results in
You get a pointer to some place where you may store 0 bytes, so nothing :-).
This can be useful because otherwise you may think
Peter Popov wrote:
Well, if it points to something, then there is space, isn't it? Unless
it is clearly mentioned in the documentation that GetMem(p,0) results in
You get a pointer to some place where you may store 0 bytes, so nothing :-).
This can be useful because otherwise you may think
You get a pointer to some place where you may store 0 bytes, so nothing
:-).
This can be useful because otherwise you may think the allocation failed
if you get nil back. (And you've disabled heap exception).
you have a point
In FPC it is done by design. If 0 bytes are asked we allocate
As I was porting things from delphi to fp today I noticed the following
difference:
Delphi (2,5) : GetMem(p, 0) will set p to nil.
FPC (2.2.2, 2.3.1) : GetMem(p, 0) will assign something to p
Clearly, the above calls are bad karma (which I have been practicing,
apparently). Delphi's
Peter Popov wrote:
size is 0 (realloc does). On the other hand, assigning something is a
bad idea too, as it suggests at least Size(pointer) amount of storage,
unless that memory spot is somehow marked as empty, etc.
How does it suggest a storage space with size 0 ?
Micha
Well, if it points to something, then there is space, isn't it? Unless it
is clearly mentioned in the documentation that GetMem(p,0) results in p
being undefined and it is put as a requirement for any custom
implementation of a heap manager.
Either way would work.
Peter
On Thu, 04 Sep
10 matches
Mail list logo