r149875, thanks! <br><br><div class="gmail_quote">On Mon, Feb 6, 2012 at 6:06 AM,  <span dir="ltr"><<a href="mailto:timurrrr@google.com">timurrrr@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Reviewers: kcc1,<br>
<br>
Message:<br>
Hi Kostya,<br>
<br>
Can you please review these Windows malloc interceptors?<br>
<br>
Thanks,<br>
Timur<br>
<br>
Description:<br>
[AddressSanitizer] The first version of Windows malloc interceptors<br>
<br>
Please review this at <a href="http://codereview.appspot.com/5636049/" target="_blank">http://codereview.appspot.com/<u></u>5636049/</a><br>
<br>
Affected files:<br>
  A lib/asan/asan_malloc_win.cc<br>
<br>
<br>
Index: lib/asan/asan_malloc_win.cc<br>
diff --git a/lib/asan/asan_malloc_win.cc b/lib/asan/asan_malloc_win.cc<br>
new file mode 100644<br>
index 000000000000000000000000000000<u></u>0000000000..<u></u>7c521a687bbc2b7f0c2db9abc6eb1b<u></u>2367cc5543<br>
--- /dev/null<br>
+++ b/lib/asan/asan_malloc_win.cc<br>
@@ -0,0 +1,57 @@<br>
+//===-- asan_malloc_win.cc ------------------------------<u></u>------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<u></u>------------------------------<u></u>----------------===//<br>
+//<br>
+// This file is a part of AddressSanitizer, an address sanity checker.<br>
+//<br>
+// Windows-specific malloc interception.<br>
+//===------------------------<u></u>------------------------------<u></u>----------------===//<br>
+#ifdef _WIN32<br>
+<br>
+#include "asan_allocator.h"<br>
+#include "asan_interceptors.h"<br>
+#include "asan_internal.h"<br>
+#include "asan_stack.h"<br>
+<br>
+namespace __asan {<br>
+void ReplaceSystemMalloc() {<br>
+  // TODO(timurrrr): investigate whether any action is needed.<br>
+}<br>
+}  // namespace __asan<br>
+<br>
+// ---------------------- Replacement functions ---------------- {{{1<br>
+using namespace __asan;  // NOLINT<br>
+<br>
+// TODO(timurrrr): Simply defining functins with the same signature in *.obj<br>
+// files overrides the standard functions in *.lib<br>
+// This works well for simple helloworld-like tests but might need to be<br>
+// revisited in the future.<br>
+<br>
+extern "C" {<br>
+void free(void *ptr) {<br>
+  GET_STACK_TRACE_HERE_FOR_FREE(<u></u>ptr);<br>
+  return asan_free(ptr, &stack);<br>
+}<br>
+<br>
+void *malloc(size_t size) {<br>
+  GET_STACK_TRACE_HERE_FOR_<u></u>MALLOC;<br>
+  return asan_malloc(size, &stack);<br>
+}<br>
+<br>
+void *calloc(size_t nmemb, size_t size) {<br>
+  GET_STACK_TRACE_HERE_FOR_<u></u>MALLOC;<br>
+  return asan_calloc(nmemb, size, &stack);<br>
+}<br>
+<br>
+void *realloc(void *ptr, size_t size) {<br>
+  GET_STACK_TRACE_HERE_FOR_<u></u>MALLOC;<br>
+  return asan_realloc(ptr, size, &stack);<br>
+}<br>
+}  // extern "C"<br>
+<br>
+#endif  // _WIN32<br>
<br>
<br>
</blockquote></div><br>