Re: Manually allocating a File

2018-02-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/18 9:59 PM, Nicholas Wilson wrote: FYI, File is a reference counted FILE* so theres not really any point of heap allocating it. More FYI, the reference counted payload is actually allocated on the C heap :) So you are wasting a lot of effort to do something that is already done.

Re: Manually allocating a File

2018-02-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 21, 2018 02:59:21 Nicholas Wilson via Digitalmars-d- learn wrote: > On Tuesday, 20 February 2018 at 15:32:45 UTC, Chris M. wrote: > > Thanks for the info, that clears things up. Like I said, it was > > more experimentation rather than me planning to actually use > > it.

Re: Manually allocating a File

2018-02-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 20 February 2018 at 15:32:45 UTC, Chris M. wrote: Thanks for the info, that clears things up. Like I said, it was more experimentation rather than me planning to actually use it. Works now with the following modifications. import std.stdio; import core.stdc.stdlib; import

Re: Manually allocating a File

2018-02-20 Thread Chris M. via Digitalmars-d-learn
On Tuesday, 20 February 2018 at 15:18:11 UTC, Adam D. Ruppe wrote: On Tuesday, 20 February 2018 at 14:56:54 UTC, Chris M. wrote: I'm doing this mainly for experimentation, but the following piece of code gives all sorts of errors. so important note: this will perform worse than the automatic

Re: Manually allocating a File

2018-02-20 Thread Uknown via Digitalmars-d-learn
On Tuesday, 20 February 2018 at 14:56:54 UTC, Chris M. wrote: I'm doing this mainly for experimentation, but the following piece of code gives all sorts of errors. Hangs, segfaults or prints nothing and exits import std.stdio; import core.stdc.stdlib; void main() { auto f = cast(File *)

Re: Manually allocating a File

2018-02-20 Thread Uknown via Digitalmars-d-learn
On Tuesday, 20 February 2018 at 15:21:59 UTC, Uknown wrote: On Tuesday, 20 February 2018 at 14:56:54 UTC, Chris M. wrote: void main() [snip] Never mind, I confused FILE* with File...

Re: Manually allocating a File

2018-02-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 20 February 2018 at 14:56:54 UTC, Chris M. wrote: I'm doing this mainly for experimentation, but the following piece of code gives all sorts of errors. so important note: this will perform worse than the automatic allocation, which just puts it down in-place. You should basically

Manually allocating a File

2018-02-20 Thread Chris M. via Digitalmars-d-learn
I'm doing this mainly for experimentation, but the following piece of code gives all sorts of errors. Hangs, segfaults or prints nothing and exits import std.stdio; import core.stdc.stdlib; void main() { auto f = cast(File *) malloc(File.sizeof); *f = File("test.txt", "r");