aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-12-18 23:24:34 +0000
committergingerBill <bill@gingerbill.org>2022-12-18 23:24:34 +0000
commit2a8fa8612de858d40b0812913817c8550db11630 (patch)
treeef8835008e3c556aa0e07ef5361bf8dca035748a /src
parente27046098b12a678e9680d73d315b4c7c19c2101 (diff)
Use `fetch_add` rather than `+=`
Diffstat (limited to 'src')
-rw-r--r--src/common_memory.cpp4
-rw-r--r--src/parser.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/common_memory.cpp b/src/common_memory.cpp
index 63b7c24ef..c8a62756a 100644
--- a/src/common_memory.cpp
+++ b/src/common_memory.cpp
@@ -165,11 +165,11 @@ gb_internal void platform_virtual_memory_protect(void *memory, isize size);
gb_printf_err("Total Usage: %lld bytes\n", cast(long long)global_platform_memory_total_usage);
GB_ASSERT_MSG(pmblock != nullptr, "Out of Virtual Memory, oh no...");
}
- global_platform_memory_total_usage += total_size;
+ global_platform_memory_total_usage.fetch_add(total_size);
return pmblock;
}
gb_internal void platform_virtual_memory_free(PlatformMemoryBlock *block) {
- global_platform_memory_total_usage -= block->total_size;
+ global_platform_memory_total_usage.fetch_sub(block->total_size);
GB_ASSERT(VirtualFree(block, 0, MEM_RELEASE));
}
gb_internal void platform_virtual_memory_protect(void *memory, isize size) {
diff --git a/src/parser.cpp b/src/parser.cpp
index 2ccdac7fa..520f123d8 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -72,7 +72,7 @@ gb_internal Ast *alloc_ast_node(AstFile *f, AstKind kind) {
node->kind = kind;
node->file_id = f ? f->id : 0;
- global_total_node_memory_allocated += size;
+ global_total_node_memory_allocated.fetch_add(size);
return node;
}