Re: free causes exception

2016-01-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/27/16 5:35 PM, Igor wrote: On Wednesday, 27 January 2016 at 14:31:20 UTC, Steven Schveighoffer wrote: All D destructors should destroy all the members. And generally speaking, if you ever plan to use a class with the GC, you should only destroy non-GC members. The GC members may already b

Re: free causes exception

2016-01-27 Thread Igor via Digitalmars-d-learn
On Wednesday, 27 January 2016 at 14:31:20 UTC, Steven Schveighoffer wrote: On 1/26/16 4:23 PM, Igor wrote: On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: [...] um? Memory manager? I am doing it manually C++ style so I don't have to worry about the god forsaken memor

Re: free causes exception

2016-01-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/16 4:23 PM, Igor wrote: On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: On 1/26/16 9:20 AM, Igor wrote: I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~this() // destructor for Fo

Re: free causes exception

2016-01-27 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:21:29 UTC, Igor wrote: That shouldn't be the case. I allocate in a static method called New once. I then deallocate in the destructor. Basically just as one would do in C++. You can't deallocate in destructor in C++, because an object can be embedded in anoth

Re: free causes exception

2016-01-26 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:23:28 UTC, Igor wrote: um? Memory manager? I am doing it manually C++ style so I don't have to worry about the god forsaken memory manager. Why is it so difficult? I create the object and release it when I need to. He's talking about *your* memory manager,

Re: free causes exception

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 01/26/2016 01:21 PM, Igor wrote: > I allocate in a static method called New once. I then deallocate in the > destructor. Basically just as one would do in C++. I would never do that in even C++. I don't know any C++ idiom that warrants 'delete this' where superior alternatives cannot be used

Re: free causes exception

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:23:28 UTC, Igor wrote: On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: On 1/26/16 9:20 AM, Igor wrote: [...] Don't do it in the destructor. I can only imagine that you are triggering the destructor with destroy? In this case, destro

Re: free causes exception

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:23:28 UTC, Igor wrote: On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: On 1/26/16 9:20 AM, Igor wrote: I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~t

Re: free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 19:34:22 UTC, Ali Çehreli wrote: On 01/26/2016 06:20 AM, Igor wrote: > I have successfully malloc'ed an object but when I go to free it in the > destructor I get an exception. The destructor simply has > > ~this() // destructor for Foo > { > core.stdc.stdlib.fr

Re: free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: On 1/26/16 9:20 AM, Igor wrote: I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~this() // destructor for Foo { core.stdc.stdlib.free(&

Re: free causes exception

2016-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/16 9:20 AM, Igor wrote: I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~this() // destructor for Foo { core.stdc.stdlib.free(&this); } auto buffer = core.stdc.stdlib.malloc(__traits(classInstanceSize

Re: free causes exception

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 01/26/2016 06:20 AM, Igor wrote: > I have successfully malloc'ed an object but when I go to free it in the > destructor I get an exception. The destructor simply has > > ~this() // destructor for Foo > { > core.stdc.stdlib.free(&this); > } That design suggests a complexity regarding objec

Re: free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 14:48:48 UTC, Daniel Kozak wrote: V Tue, 26 Jan 2016 14:20:29 + Igor via Digitalmars-d-learn napsáno: [...] core.stdc.stdlib.free(cast(void *)this); I still get an exception: Exception thrown at 0x7FF6C7CA3700 in test.exe: 0xC005: Access violati

Re: free causes exception

2016-01-26 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 26 Jan 2016 15:24:00 + Igor via Digitalmars-d-learn napsáno: > On Tuesday, 26 January 2016 at 14:48:48 UTC, Daniel Kozak wrote: > > V Tue, 26 Jan 2016 14:20:29 + > > Igor via Digitalmars-d-learn > > napsáno: > > > >> [...] > > > > core.stdc.stdlib.free(cast(void *)this); >

Re: free causes exception

2016-01-26 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 26 Jan 2016 14:20:29 + Igor via Digitalmars-d-learn napsáno: > I have successfully malloc'ed an object but when I go to free it > in the destructor I get an exception. The destructor simply has > > ~this() // destructor for Foo > { > core.stdc.stdlib.free(&this); > } > > > aut

free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~this() // destructor for Foo { core.stdc.stdlib.free(&this); } auto buffer = core.stdc.stdlib.malloc(__traits(classInstanceSize, App))[0..__traits(classInstanc