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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // -In singly linked lists, the |next| pointer is stored in the first N | 52 // -In singly linked lists, the |next| pointer is stored in the first N |
53 // bytes of the node. | 53 // bytes of the node. |
54 // | 54 // |
55 // For both types of lists: when a pop operation is performed on a non | 55 // For both types of lists: when a pop operation is performed on a non |
56 // empty list, the new list head becomes that which is pointed to by | 56 // empty list, the new list head becomes that which is pointed to by |
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 #ifdef TCMALLOC_USE_DOUBLYLINKED_FREELIST | |
63 | |
64 #include <stddef.h> | 62 #include <stddef.h> |
65 #include "free_list.h" | 63 #include "free_list.h" |
66 | 64 |
| 65 #if defined(TCMALLOC_USE_DOUBLYLINKED_FREELIST) |
| 66 |
67 // TODO(jar): We should use C++ rather than a macro here. | 67 // TODO(jar): We should use C++ rather than a macro here. |
68 #define MEMORY_CHECK(v1, v2) \ | 68 #define MEMORY_CHECK(v1, v2) \ |
69 if (v1 != v2) CRASH("Memory corruption detected.\n") | 69 if (v1 != v2) CRASH("Memory corruption detected.\n") |
70 | 70 |
71 namespace { | 71 namespace { |
72 void EnsureNonLoop(void* node, void* next) { | 72 void EnsureNonLoop(void* node, void* next) { |
73 // 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 |
74 // only look for an immediate loop (cycle back to ourself). | 74 // only look for an immediate loop (cycle back to ourself). |
75 if (node != next) return; | 75 if (node != next) return; |
76 CRASH("Circular loop in list detected: %p\n", next); | 76 CRASH("Circular loop in list detected: %p\n", next); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 namespace { | 221 namespace { |
222 | 222 |
223 inline void FL_SetNext(void *t, void *n) { | 223 inline void FL_SetNext(void *t, void *n) { |
224 tcmalloc::SLL_SetNext(t,n); | 224 tcmalloc::SLL_SetNext(t,n); |
225 } | 225 } |
226 | 226 |
227 } | 227 } |
228 | 228 |
229 #endif // TCMALLOC_USE_DOUBLYLINKED_FREELIST | 229 #endif // TCMALLOC_USE_DOUBLYLINKED_FREELIST |
OLD | NEW |