Minor cleanup of DN

This commit is contained in:
2026-06-24 22:46:40 +10:00
parent aeaa497a7b
commit 924a092874
3 changed files with 26 additions and 41 deletions
+3 -7
View File
@@ -6,6 +6,9 @@
#define DN_ARENA_TEMP_MEM_UAF_TRACE_ON_BY_DEFAULT 0 #define DN_ARENA_TEMP_MEM_UAF_TRACE_ON_BY_DEFAULT 0
#define DN_WITH_OS 1 #define DN_WITH_OS 1
#define DN_WITH_NET 1 #define DN_WITH_NET 1
#if defined(DN_PLATFORM_EMSCRIPTEN)
#define DN_WITH_NET_EMSCRIPTEN 1
#endif
#include "../dn.h" #include "../dn.h"
#if DN_WITH_NET_CURL #if DN_WITH_NET_CURL
@@ -14,13 +17,6 @@
#endif #endif
#include "../dn.cpp" #include "../dn.cpp"
#if defined(DN_PLATFORM_EMSCRIPTEN)
#include <emscripten/emscripten.h>
#include <emscripten/fetch.h>
#include "../Extra/dn_net_emscripten.h"
#include "../Extra/dn_net_emscripten.cpp"
#endif
#define DN_UT_IMPLEMENTATION #define DN_UT_IMPLEMENTATION
#include "../Standalone/dn_utest.h" #include "../Standalone/dn_utest.h"
#include "../Extra/dn_tests.cpp" #include "../Extra/dn_tests.cpp"
+1 -1
View File
@@ -219,7 +219,7 @@ DN_API void DN_OS_GenBytesSecure(void *buffer, DN_U32 size)
DN_API bool DN_OS_SetEnvVar(DN_Str8 name, DN_Str8 value) DN_API bool DN_OS_SetEnvVar(DN_Str8 name, DN_Str8 value)
{ {
DN_VerifyWarning(false, "Unimplemented function"); DN_VerifyWarningF(false, "Unimplemented function");
(void)name; (void)name;
(void)value; (void)value;
bool result = false; bool result = false;
+22 -33
View File
@@ -4,39 +4,26 @@
// NOTE: DN // NOTE: DN
// NOTE: Getting Started // NOTE: Getting Started
// Include this mega header `dn.h` and define the following symbols to `1` to conditionally // - Copy the entire DN folder to your project and include `dn.h` alongside your headers and
// enable the interfaces for those features. Additionally in the same or different translation // include `dn.cpp` in one of your implementation files that has `dn.h` included in its scope,
// unit, include `dn.cpp` with the same symbols defined to enable the implementation of these // an example. There are #defines to selectively enable features of the library (see the
// features. // configuration section for more info), example:
//
// See the configuration section for more information on other symbols that can be defined.
//
// The following is a single translation unit example:
/* /*
#define DN_WITH_OS 1 #define DN_WITH_OS 1 // Enable OS features (like virtual mem, TLS, file system, threads)
#define DN_WITH_NET 0 #include "dn.h"
#define DN_WITH_NET_CURL 0
#define DN_WITH_NET_EMSCRIPTEN 0
#include "dn.h"
#define DN_CPP_WITH_TESTS 1 #define DN_CPP_WITH_TESTS 1
#include "dn.cpp" #include "dn.cpp"
int main() int main()
{ {
DN_Core core = {}; DN_Core core = {};
DN_Init(&core, DN_InitFlags_Nil, DN_TCInitArgsDefault()); DN_Init(&core, DN_InitFlags_Nil, DN_TCInitArgsDefault());
return 0; return 0;
} }
*/ */
// - The base layer (dn_base.h) which provides primitives that do not require a host operating // - `DN/Standalone` contains utilities that are self-contained and can be used without `dn.h` in
// system (e.g. freestanding) such as string manipulation, compiler intrinsics and containers. // a similar manner, typically a single header and single implementation file.
// This layer is unconditionallly always available by compiling with this library.
//
// - The OS layer (dn_os.h) which provides primitives that use the OS such as file IO, threading
// synchronisation, memory allocation. This layer is OPTIONAL.
//
// - Extra layer provides helper utilities that are opt-in. These layers are OPTIONAL.
// NOTE: Configuration // NOTE: Configuration
@@ -2431,10 +2418,12 @@ DN_API DN_F32 DN_EpsilonClampF32
DN_API DN_MemStats DN_MemStatsSum (DN_MemStats lhs, DN_MemStats rhs); DN_API DN_MemStats DN_MemStatsSum (DN_MemStats lhs, DN_MemStats rhs);
DN_API DN_MemStats DN_MemStatsSumArray (DN_MemStats const *array, DN_USize size); DN_API DN_MemStats DN_MemStatsSumArray (DN_MemStats const *array, DN_USize size);
// NOTE: `MemList` is an implementation of a classical `Arena` (e.g. bump allocator, can dynamically // NOTE: MemList
// grow, frees by bumping pointer back, sub-divides a block of memory). The term `Arena` is reserved // Overview
// as a thin-layer over the functionality here to provide some use-after-free protection. See // `MemList` is an implementation of a classical `Arena` (e.g. bump allocator, can dynamically
// `Arena` for more info. // grow, frees by bumping pointer back, sub-divides a block of memory). The term `Arena` is
// reserved as a thin-layer over the functionality here to provide some use-after-free protection.
// See `Arena` for more info.
DN_API DN_MemList DN_MemListFromBuffer (void *buffer, DN_USize size, DN_MemFlags flags); DN_API DN_MemList DN_MemListFromBuffer (void *buffer, DN_USize size, DN_MemFlags flags);
DN_API DN_MemList DN_MemListFromMemFuncs (DN_U64 reserve, DN_U64 commit, DN_MemFlags flags, DN_MemFuncs mem_funcs); DN_API DN_MemList DN_MemListFromMemFuncs (DN_U64 reserve, DN_U64 commit, DN_MemFlags flags, DN_MemFuncs mem_funcs);
DN_API void DN_MemListDeinit (DN_MemList *mem); DN_API void DN_MemListDeinit (DN_MemList *mem);