Rant of the day
Rumbu
rumbu at rumbu.ro
Mon Jan 25 19:53:11 UTC 2021
On Monday, 25 January 2021 at 18:48:46 UTC, Imperatorn wrote:
> On Monday, 25 January 2021 at 15:07:02 UTC, Rumbu wrote:
>> After 1 year or something, I tried D again.
>>
>> Do you know what happens if you write GC.Free insead of
>> GC.free?
>>
>> 27 lines of code, 26 errors.
>>
>> https://imgur.com/a/DlackXp
>
> Curious, why didn't u want to use new/delete/destroy?
iport std.mmfile;
struct Database
{
this(string filename)
{
this.filename = filename;
file = new MmFile(filename, MmFile.Mode.read, 0, null);
}
~this()
{
if (file)
{
destroy(file);
GC.free(&file);
}
}
}
//somewhere in code:
{
Database db = Database("somefile");
....
//here at the end of scope I want to be sure that file map is
closed.
}
More information about the Digitalmars-d
mailing list