Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit8eb996ccb042a9ddb0c69ca1d7083c431f6e03b0 (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-04-30 11:04:29 +0300
Committer
 Syndamia <kamen@syndamia.com>
2026-05-12 07:08:56 +0300
Files3cdf861543eb1387484793b652317bdfd87a5529
foollib-8eb996ccb042a9ddb0c69ca1d7083c431f6e03b0.tar
foollib-8eb996ccb042a9ddb0c69ca1d7083c431f6e03b0.tar.gz
foollib-8eb996ccb042a9ddb0c69ca1d7083c431f6e03b0.zip
Parent58374e851737e1bcbc697af9e14d630be66e1f4f (diff)
feat(MemoryManager): Implement global M_STD
This is useful in case you don't want to use a specific memory manager. Anywhere you've included a feature, which uses memory manager, you can always provide M_STD without having to create (and manage) your own value.
2 files changed, 11 insertions, 0 deletions
-rw-r--r--MemoryManager.c9
-rw-r--r--MemoryManager.h2
diff --git a/MemoryManager.c b/MemoryManager.c
index dd3a7fc..3f8d054 100644
--- a/MemoryManager.c
+++ b/MemoryManager.c
@@ -38,6 +38,14 @@ std_destroy(MemoryManager *mm) {
return R_Unavailable;
}
+const MemoryManager M_STD = {
+ .alloc = &std_alloc,
+ .realloc = &std_realloc,
+ .free = &std_free,
+ .destroy = &std_destroy,
+ .priv = NULL,
+ };
+
MemoryManager
M_std() {
return (MemoryManager){
@@ -45,6 +53,7 @@ M_std() {
.realloc = &std_realloc,
.free = &std_free,
.destroy = &std_destroy,
+ .priv = NULL,
};
}
diff --git a/MemoryManager.h b/MemoryManager.h
index 1025e69..e2b0996 100644
--- a/MemoryManager.h
+++ b/MemoryManager.h
@@ -11,6 +11,8 @@ typedef struct MemoryManager {
void *priv;
} MemoryManager;
+extern const MemoryManager M_STD;
+
MemoryManager M_std();
MemoryManager M_std_tracked();