| OLD | NEW |
| 1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // _type_ is usually "normal" but can also be "minimal", "strict", or | 44 // _type_ is usually "normal" but can also be "minimal", "strict", or |
| 45 // "draconian". (See the html file for other options, like 'local'.) | 45 // "draconian". (See the html file for other options, like 'local'.) |
| 46 // | 46 // |
| 47 // After that, just run your binary. If the heap-checker detects | 47 // After that, just run your binary. If the heap-checker detects |
| 48 // a memory leak at program-exit, it will print instructions on how | 48 // a memory leak at program-exit, it will print instructions on how |
| 49 // to track down the leak. | 49 // to track down the leak. |
| 50 | 50 |
| 51 #ifndef BASE_HEAP_CHECKER_H_ | 51 #ifndef BASE_HEAP_CHECKER_H_ |
| 52 #define BASE_HEAP_CHECKER_H_ | 52 #define BASE_HEAP_CHECKER_H_ |
| 53 | 53 |
| 54 #include "config.h" | |
| 55 | |
| 56 #include <sys/types.h> // for size_t | 54 #include <sys/types.h> // for size_t |
| 57 #ifdef HAVE_STDINT_H | 55 // I can't #include config.h in this public API file, but I should |
| 56 // really use configure (and make malloc_extension.h a .in file) to |
| 57 // figure out if the system has stdint.h or not. But I'm lazy, so |
| 58 // for now I'm assuming it's a problem only with MSVC. |
| 59 #ifndef _MSC_VER |
| 58 #include <stdint.h> // for uintptr_t | 60 #include <stdint.h> // for uintptr_t |
| 59 #endif | 61 #endif |
| 60 #include <stdarg.h> // for va_list | 62 #include <stdarg.h> // for va_list |
| 61 #include <vector> | 63 #include <vector> |
| 62 | 64 |
| 63 // Annoying stuff for windows -- makes sure clients can import these functions | 65 // Annoying stuff for windows -- makes sure clients can import these functions |
| 64 #ifndef PERFTOOLS_DLL_DECL | 66 #ifndef PERFTOOLS_DLL_DECL |
| 65 # ifdef _WIN32 | 67 # ifdef _WIN32 |
| 66 # define PERFTOOLS_DLL_DECL __declspec(dllimport) | 68 # define PERFTOOLS_DLL_DECL __declspec(dllimport) |
| 67 # else | 69 # else |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // (they run only if we are doing heap leak checking.) | 409 // (they run only if we are doing heap leak checking.) |
| 408 // 'body' should be the cleanup code to run. 'name' doesn't matter, | 410 // 'body' should be the cleanup code to run. 'name' doesn't matter, |
| 409 // but must be unique amongst all REGISTER_HEAPCHECK_CLEANUP calls. | 411 // but must be unique amongst all REGISTER_HEAPCHECK_CLEANUP calls. |
| 410 #define REGISTER_HEAPCHECK_CLEANUP(name, body) \ | 412 #define REGISTER_HEAPCHECK_CLEANUP(name, body) \ |
| 411 namespace { \ | 413 namespace { \ |
| 412 void heapcheck_cleanup_##name() { body; } \ | 414 void heapcheck_cleanup_##name() { body; } \ |
| 413 static HeapCleaner heapcheck_cleaner_##name(&heapcheck_cleanup_##name); \ | 415 static HeapCleaner heapcheck_cleaner_##name(&heapcheck_cleanup_##name); \ |
| 414 } | 416 } |
| 415 | 417 |
| 416 #endif // BASE_HEAP_CHECKER_H_ | 418 #endif // BASE_HEAP_CHECKER_H_ |
| OLD | NEW |