Windows printing

2021-10-06 Thread frame via Digitalmars-d-learn
Is there some Windows expert or someone you can tell me if I do things wrong? I can open the printer and also print but I'm failing to restore the printer settings from a file. ```d import core.sys.windows.windows; import core.sys.windows.winspool; import std; pragma(lib, "winspool.lib"); e

Re: Managing malloced memory

2021-10-06 Thread anon via Digitalmars-d-learn
I found https://dlang.org/library/std/typecons/unique.html , which I think solves my problem by disabling copying. Thanks for the help.

Re: Managing malloced memory

2021-10-06 Thread anon via Digitalmars-d-learn
Sorry for messed up post, fixed it. On Wednesday, 6 October 2021 at 18:29:34 UTC, Steven Schveighoffer wrote: You can return this thing and pass it around, and the GC will keep it alive until it's not needed. Then on collection, the value is freed. Is the gc required to call ~this() on the s

Re: Managing malloced memory

2021-10-06 Thread anon via Digitalmars-d-learn
Thanks for the help. On Wednesday, 6 October 2021 at 18:29:34 UTC, Steven Schveighoffer wrote: You can return this thing and pass it around, and the GC will keep it alive until it's not needed. Then on collection, the value is freed. Is the gc required to call ~this() on the struct? I remember

Re: Managing malloced memory

2021-10-06 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 06, 2021 at 06:06:38PM +, anon via Digitalmars-d-learn wrote: > I interface to a C library that gives me a malloced object. How can I manage > that pointer so that it gets freed automatically. > What I've thought of so far: [...] > * struct wrapped in automem/ refcounted: The struct

Re: Managing malloced memory

2021-10-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/6/21 2:06 PM, anon wrote: I interface to a C library that gives me a malloced object. How can I manage that pointer so that it gets freed automatically. What I've thought of so far: * scope(exit): not an option because I want to return that memory * struct wrapper: Doesn't work because if

Managing malloced memory

2021-10-06 Thread anon via Digitalmars-d-learn
I interface to a C library that gives me a malloced object. How can I manage that pointer so that it gets freed automatically. What I've thought of so far: * scope(exit): not an option because I want to return that memory * struct wrapper: Doesn't work because if I pass it to another function, t