aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap.cc43
-rw-r--r--src/main.cc (renamed from src/change_log.cc)42
2 files changed, 44 insertions, 41 deletions
diff --git a/src/bootstrap.cc b/src/bootstrap.cc
new file mode 100644
index 0000000..309ff20
--- /dev/null
+++ b/src/bootstrap.cc
@@ -0,0 +1,43 @@
+#include "actual.h"
+
+#include "init/alloc.h"
+
+void free(void* ptr) {
+ static actual::ptr<void, void*> actual_free{};
+
+ if ( !actual_free ) {
+ actual_free = actual::get_ptr<decltype(actual_free)>("free");
+ }
+
+ if ( !init::from_static_buffer(ptr) ) {
+ actual_free(ptr);
+ }
+}
+
+void* malloc(size_t size) {
+ static actual::ptr<void*, size_t> actual_malloc{};
+
+ if ( init::dlsymContext::is_active() ) {
+ return init::static_malloc(size);
+ } else {
+ if ( !actual_malloc ) {
+ actual_malloc = actual::get_ptr<decltype(actual_malloc)>("malloc");
+ }
+
+ return actual_malloc(size);
+ }
+}
+
+void* calloc(size_t block, size_t size) {
+ static actual::ptr<void*, size_t, size_t> actual_calloc{};
+
+ if ( init::dlsymContext::is_active() ) {
+ return init::static_calloc(block, size);
+ } else {
+ if ( !actual_calloc ) {
+ actual_calloc = actual::get_ptr<decltype(actual_calloc)>("calloc");
+ }
+
+ return actual_calloc(block, size);
+ }
+}
diff --git a/src/change_log.cc b/src/main.cc
index 5f3b4f8..8b6ca23 100644
--- a/src/change_log.cc
+++ b/src/main.cc
@@ -1,8 +1,8 @@
#include "actual.h"
-#include "init/alloc.h"
#include "utility/io.h"
#include "utility/logger.h"
+
#include "tracking/path_matcher.h"
#include "tracking/change_tracker.h"
@@ -82,46 +82,6 @@ inline void track_remove(const std::string& path) {
}
}
-void free(void* ptr) {
- static actual::ptr<void, void*> actual_free{};
-
- if ( !actual_free ) {
- actual_free = actual::get_ptr<decltype(actual_free)>("free");
- }
-
- if ( !init::from_static_buffer(ptr) ) {
- actual_free(ptr);
- }
-}
-
-void* malloc(size_t size) {
- static actual::ptr<void*, size_t> actual_malloc{};
-
- if ( init::dlsymContext::is_active() ) {
- return init::static_malloc(size);
- } else {
- if ( !actual_malloc ) {
- actual_malloc = actual::get_ptr<decltype(actual_malloc)>("malloc");
- }
-
- return actual_malloc(size);
- }
-}
-
-void* calloc(size_t block, size_t size) {
- static actual::ptr<void*, size_t, size_t> actual_calloc{};
-
- if ( init::dlsymContext::is_active() ) {
- return init::static_calloc(block, size);
- } else {
- if ( !actual_calloc ) {
- actual_calloc = actual::get_ptr<decltype(actual_calloc)>("calloc");
- }
-
- return actual_calloc(block, size);
- }
-}
-
ssize_t write(int fd, const void* buffer, size_t count) {
static actual::ptr<ssize_t, int, const void*, size_t> actual_write{};