OLD | NEW |
1 // Copyright (c) 2011, Google Inc. | 1 // Copyright (c) 2011, 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // the former head's |next| pointer. If the list is doubly linked, the | 57 // the former head's |next| pointer. If the list is doubly linked, the |
58 // new head |previous| pointer gets changed from pointing to the former | 58 // new head |previous| pointer gets changed from pointing to the former |
59 // head to NULL. | 59 // head to NULL. |
60 | 60 |
61 | 61 |
62 #include <stddef.h> | 62 #include <stddef.h> |
63 #include "free_list.h" | 63 #include "free_list.h" |
64 | 64 |
65 #if defined(TCMALLOC_USE_DOUBLYLINKED_FREELIST) | 65 #if defined(TCMALLOC_USE_DOUBLYLINKED_FREELIST) |
66 | 66 |
67 using tcmalloc::kCrash; | |
68 | |
69 // TODO(jar): We should use C++ rather than a macro here. | 67 // TODO(jar): We should use C++ rather than a macro here. |
70 #define MEMORY_CHECK(v1, v2) \ | 68 #define MEMORY_CHECK(v1, v2) \ |
71 if (v1 != v2) Log(kCrash, __FILE__, __LINE__, "Memory corruption detected.\n") | 69 if (v1 != v2) CRASH("Memory corruption detected.\n") |
72 | 70 |
73 namespace { | 71 namespace { |
74 void EnsureNonLoop(void* node, void* next) { | 72 void EnsureNonLoop(void* node, void* next) { |
75 // We only have time to do minimal checking. We don't traverse the list, but | 73 // We only have time to do minimal checking. We don't traverse the list, but |
76 // only look for an immediate loop (cycle back to ourself). | 74 // only look for an immediate loop (cycle back to ourself). |
77 if (node != next) return; | 75 if (node != next) return; |
78 Log(kCrash, __FILE__, __LINE__, "Circular loop in list detected: %p\n", next); | 76 CRASH("Circular loop in list detected: %p\n", next); |
79 } | 77 } |
80 | 78 |
81 // Returns value of the |previous| pointer w/out running a sanity | 79 // Returns value of the |previous| pointer w/out running a sanity |
82 // check. | 80 // check. |
83 inline void *FL_Previous_No_Check(void *t) { | 81 inline void *FL_Previous_No_Check(void *t) { |
84 return reinterpret_cast<void**>(t)[1]; | 82 return reinterpret_cast<void**>(t)[1]; |
85 } | 83 } |
86 | 84 |
87 // Returns value of the |next| pointer w/out running a sanity check. | 85 // Returns value of the |next| pointer w/out running a sanity check. |
88 inline void *FL_Next_No_Check(void *t) { | 86 inline void *FL_Next_No_Check(void *t) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 220 |
223 namespace { | 221 namespace { |
224 | 222 |
225 inline void FL_SetNext(void *t, void *n) { | 223 inline void FL_SetNext(void *t, void *n) { |
226 tcmalloc::SLL_SetNext(t,n); | 224 tcmalloc::SLL_SetNext(t,n); |
227 } | 225 } |
228 | 226 |
229 } | 227 } |
230 | 228 |
231 #endif // TCMALLOC_USE_DOUBLYLINKED_FREELIST | 229 #endif // TCMALLOC_USE_DOUBLYLINKED_FREELIST |
OLD | NEW |