aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-02-17 21:58:38 +0100
committerAdrian Kummerlaender2016-02-17 21:58:38 +0100
commit3294bfe789ff354ca372f7c32275316bf4491ca5 (patch)
tree0ee3f580402b87edb57129d2ca56460657d5d609 /src
parentaf756d78ac042a2eed2417c5250d4b675d43bf93 (diff)
downloadchange-3294bfe789ff354ca372f7c32275316bf4491ca5.tar
change-3294bfe789ff354ca372f7c32275316bf4491ca5.tar.gz
change-3294bfe789ff354ca372f7c32275316bf4491ca5.tar.bz2
change-3294bfe789ff354ca372f7c32275316bf4491ca5.tar.lz
change-3294bfe789ff354ca372f7c32275316bf4491ca5.tar.xz
change-3294bfe789ff354ca372f7c32275316bf4491ca5.tar.zst
change-3294bfe789ff354ca372f7c32275316bf4491ca5.zip
Separate static allocator from payload function interpositions
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{};