Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 8f32f19

Browse files
authored
Merge pull request #2386 from radcapricorn/pureFreePosix
POSIX `free` purity
2 parents aace1c5 + e38a533 commit 8f32f19

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/core/memory.d

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,21 @@ void* pureRealloc()(void* ptr, size_t size) @system pure @nogc nothrow
884884
fakePureErrno = errnosave;
885885
return ret;
886886
}
887+
887888
/// ditto
888889
void pureFree()(void* ptr) @system pure @nogc nothrow
889890
{
890-
const errnosave = fakePureErrno;
891-
fakePureFree(ptr);
892-
fakePureErrno = errnosave;
891+
version (Posix)
892+
{
893+
// POSIX free doesn't set errno
894+
fakePureFree(ptr);
895+
}
896+
else
897+
{
898+
const errnosave = fakePureErrno;
899+
fakePureFree(ptr);
900+
fakePureErrno = errnosave;
901+
}
893902
}
894903

895904
///

0 commit comments

Comments
 (0)