OSDN Git Service

Add strdup to tracked allocations
authorZach Johnson <zachoverflow@google.com>
Wed, 27 Aug 2014 03:15:19 +0000 (20:15 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Mon, 16 Mar 2015 23:51:30 +0000 (16:51 -0700)
osi/include/allocator.h
osi/src/allocator.c

index 2cb34b8..0de4727 100644 (file)
@@ -32,6 +32,8 @@ typedef struct {
 extern const allocator_t allocator_malloc;
 extern const allocator_t allocator_calloc;
 
+char *osi_strdup(const char *str);
+
 void *osi_malloc(size_t size);
 void *osi_calloc(size_t size);
 void osi_free(void *ptr);
index be3be2d..c0bf79b 100644 (file)
 #include "allocator.h"
 #include "allocation_tracker.h"
 
+char *osi_strdup(const char *str) {
+  char *ret = strdup(str);
+  allocation_tracker_notify_alloc(ret, strlen(ret));
+  return ret;
+}
+
 void *osi_malloc(size_t size) {
   void *ptr = malloc(size);
   allocation_tracker_notify_alloc(ptr, size);