aboutsummaryrefslogtreecommitdiffstats
path: root/api/session.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-04 12:55:25 +0100
committerSimon Rozman <simon@rozman.si>2020-11-04 13:21:43 +0100
commit5d1efa847fc038d8c34b0e050a30bb07c6cb686e (patch)
tree850e61a4a7ec676cb5a67b1dd6e75e884b56a4a6 /api/session.c
parentapi: concatenate function name at runtime (diff)
downloadwintun-5d1efa847fc038d8c34b0e050a30bb07c6cb686e.tar.xz
wintun-5d1efa847fc038d8c34b0e050a30bb07c6cb686e.zip
api: use a logging alloc function
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--api/session.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/api/session.c b/api/session.c
index c4e1c04..867ac04 100644
--- a/api/session.c
+++ b/api/session.c
@@ -73,11 +73,10 @@ _Return_type_success_(return != NULL) TUN_SESSION *WINAPI
WintunStartSession(_In_ const WINTUN_ADAPTER *Adapter, _In_ DWORD Capacity)
{
DWORD LastError;
- TUN_SESSION *Session = HeapAlloc(ModuleHeap, HEAP_ZERO_MEMORY, sizeof(TUN_SESSION));
+ TUN_SESSION *Session = Zalloc(sizeof(TUN_SESSION));
if (!Session)
{
- LOG(WINTUN_LOG_ERR, L"Out of memory");
- LastError = ERROR_OUTOFMEMORY;
+ LastError = GetLastError();
goto out;
}
const ULONG RingSize = TUN_RING_SIZE(Capacity);
@@ -146,7 +145,7 @@ cleanupToken:
cleanupAllocatedRegion:
VirtualFree(AllocatedRegion, 0, MEM_RELEASE);
cleanupRings:
- HeapFree(ModuleHeap, 0, Session);
+ Free(Session);
out:
SetLastError(LastError);
return NULL;
@@ -162,7 +161,7 @@ WintunEndSession(_In_ TUN_SESSION *Session)
CloseHandle(Session->Descriptor.Send.TailMoved);
CloseHandle(Session->Descriptor.Receive.TailMoved);
VirtualFree(Session->Descriptor.Send.Ring, 0, MEM_RELEASE);
- HeapFree(ModuleHeap, 0, Session);
+ Free(Session);
}
HANDLE WINAPI