Re: Please help with GC exception!

2012-05-09 Thread Gor Gyolchanyan
I could use std.c.stdlib.realloc (and I am using, since the GC one throws). I was using the GC version, because GC allows to extend without moving, which can be used in optimized memory buffer structures, that I'm trying to implement. Before trying the GC version, I tried to look for C solutions an

Re: Please help with GC exception!

2012-05-09 Thread Sean Kelly
On May 9, 2012, at 8:28 AM, Gor Gyolchanyan wrote: > I have a structure: > > private struct Block > { > this(size_t n) { /* allocate n bytes with GC.malloc */ } > this(this) { /* deep-copy the bytes */ } > ~this() { /* deallocate them with GC.free */ } > } > > And a class: > >

Re: Please help with GC exception!

2012-05-09 Thread Steven Schveighoffer
On Wed, 09 May 2012 12:52:43 -0400, Gor Gyolchanyan wrote: I got your point. Thanks for the reply! Wouldn't it make more sense for GC to ignore second deallocation? The memory may have already been reallocated elsewhere! If this was the case, data, which is know to become garbage would be

Re: Please help with GC exception!

2012-05-09 Thread Kevin Cox
On May 9, 2012 12:53 PM, "Gor Gyolchanyan" wrote: > Wouldn't it make more sense for GC to ignore second deallocation? > If this was the case, data, which is know to become garbage would be > deallocated right away. > On the other hand, I might as well use std.c.stdlib.realloc for these cases. No,

Re: Please help with GC exception!

2012-05-09 Thread Gor Gyolchanyan
I got your point. Thanks for the reply! Wouldn't it make more sense for GC to ignore second deallocation? If this was the case, data, which is know to become garbage would be deallocated right away. On the other hand, I might as well use std.c.stdlib.realloc for these cases. On Wed, May 9, 2012 at

Re: Please help with GC exception!

2012-05-09 Thread Steven Schveighoffer
On Wed, 09 May 2012 12:12:55 -0400, Gor Gyolchanyan wrote: I'm not deleting the member. I'm deleting memory, allocated by the member. The member is a struct, so it's fully contained within the class's block. Therefore, the memory block is a member, even if indirectly so. If GC delete

Re: Please help with GC exception!

2012-05-09 Thread Gor Gyolchanyan
I'm not deleting the member. I'm deleting memory, allocated by the member. If GC deleted it before the object, the same error would appear when I forced a GC collection cycle. Also, docs clearly say, that I'm free to delete the memory myself. This means, that I shouldn't care if a collection cycle

Re: Please help with GC exception!

2012-05-09 Thread Steven Schveighoffer
On Wed, 09 May 2012 11:28:30 -0400, Gor Gyolchanyan wrote: I have a structure: private struct Block { this(size_t n) { /* allocate n bytes with GC.malloc */ } this(this) { /* deep-copy the bytes */ } ~this() { /* deallocate them with GC.free */ } } And a class: fina

Please help with GC exception!

2012-05-09 Thread Gor Gyolchanyan
I have a structure: private struct Block { this(size_t n) { /* allocate n bytes with GC.malloc */ } this(this) { /* deep-copy the bytes */ } ~this() { /* deallocate them with GC.free */ } } And a class: final class Region { private Block _block; alias _blo