Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Unified Diff: base/allocator/allocator_interception_mac.h

Issue 2650363002: Refactor allocator_interception_mac to use {Store,Replace}ZoneFunctions. (Closed)
Patch Set: Fix ASAN build error. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/allocator/allocator_interception_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/allocator_interception_mac.h
diff --git a/base/allocator/allocator_interception_mac.h b/base/allocator/allocator_interception_mac.h
index 6be5210947e1f6c8e51b9654040fe03d48c0a2a7..87cbf4896e941178837efa0843f881369c36975b 100644
--- a/base/allocator/allocator_interception_mac.h
+++ b/base/allocator/allocator_interception_mac.h
@@ -5,11 +5,43 @@
#ifndef BASE_ALLOCATOR_ALLOCATOR_INTERCEPTION_MAC_H_
#define BASE_ALLOCATOR_ALLOCATOR_INTERCEPTION_MAC_H_
+#include <malloc/malloc.h>
#include <stddef.h>
+#include "third_party/apple_apsl/malloc.h"
+
namespace base {
namespace allocator {
+typedef void* (*malloc_type)(struct _malloc_zone_t* zone, size_t size);
+typedef void* (*calloc_type)(struct _malloc_zone_t* zone,
+ size_t num_items,
+ size_t size);
+typedef void* (*valloc_type)(struct _malloc_zone_t* zone, size_t size);
+typedef void (*free_type)(struct _malloc_zone_t* zone, void* ptr);
+typedef void* (*realloc_type)(struct _malloc_zone_t* zone,
+ void* ptr,
+ size_t size);
+typedef void* (*memalign_type)(struct _malloc_zone_t* zone,
+ size_t alignment,
+ size_t size);
+
+struct MallocZoneFunctions {
+ malloc_type malloc = nullptr;
+ calloc_type calloc = nullptr;
+ valloc_type valloc = nullptr;
+ free_type free = nullptr;
+ realloc_type realloc = nullptr;
+ memalign_type memalign = nullptr;
+};
+
+// Saves the function pointers currently used by |zone| into |functions|.
+void StoreZoneFunctions(ChromeMallocZone* zone, MallocZoneFunctions* functions);
+
+// Updates the malloc zone to use the functions specified by |functions|.
+void ReplaceZoneFunctions(ChromeMallocZone* zone,
+ const MallocZoneFunctions* functions);
+
// Calls the original implementation of malloc/calloc prior to interception.
bool UncheckedMallocMac(size_t size, void** result);
bool UncheckedCallocMac(size_t num_items, size_t size, void** result);
« no previous file with comments | « no previous file | base/allocator/allocator_interception_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698