| 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 22 matching lines...) Expand all Loading... |
| 33 // This file contains declarations of functions that implement doubly | 33 // This file contains declarations of functions that implement doubly |
| 34 // linked lists and definitions of functions that implement singly | 34 // linked lists and definitions of functions that implement singly |
| 35 // linked lists. It also contains macros to tell the SizeMap class | 35 // linked lists. It also contains macros to tell the SizeMap class |
| 36 // how much space a node in the freelist needs so that SizeMap can | 36 // how much space a node in the freelist needs so that SizeMap can |
| 37 // create large enough size classes. | 37 // create large enough size classes. |
| 38 | 38 |
| 39 #ifndef TCMALLOC_FREE_LIST_H_ | 39 #ifndef TCMALLOC_FREE_LIST_H_ |
| 40 #define TCMALLOC_FREE_LIST_H_ | 40 #define TCMALLOC_FREE_LIST_H_ |
| 41 | 41 |
| 42 #include <stddef.h> | 42 #include <stddef.h> |
| 43 #include "internal_logging.h" // For CRASH() macro. | 43 #include "internal_logging.h" |
| 44 #include "linked_list.h" | 44 #include "linked_list.h" |
| 45 | 45 |
| 46 // Remove to enable singly linked lists (the default for open source tcmalloc). | 46 // Remove to enable singly linked lists (the default for open source tcmalloc). |
| 47 #define TCMALLOC_USE_DOUBLYLINKED_FREELIST | 47 #define TCMALLOC_USE_DOUBLYLINKED_FREELIST |
| 48 | 48 |
| 49 namespace tcmalloc { | 49 namespace tcmalloc { |
| 50 | 50 |
| 51 #if defined(TCMALLOC_USE_DOUBLYLINKED_FREELIST) | 51 #if defined(TCMALLOC_USE_DOUBLYLINKED_FREELIST) |
| 52 | 52 |
| 53 // size class information for common.h. | 53 // size class information for common.h. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 inline void FL_Init(void *t) { | 71 inline void FL_Init(void *t) { |
| 72 SLL_SetNext(t, NULL); | 72 SLL_SetNext(t, NULL); |
| 73 } | 73 } |
| 74 | 74 |
| 75 inline void FL_Push(void **list, void *element) { | 75 inline void FL_Push(void **list, void *element) { |
| 76 if(*list != element) { | 76 if(*list != element) { |
| 77 SLL_Push(list,element); | 77 SLL_Push(list,element); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 CRASH("Double Free of %p detected", element); | 80 Log(kCrash, __FILE__, __LINE__, "Double Free of %p detected", element); |
| 81 } | 81 } |
| 82 | 82 |
| 83 inline void *FL_Pop(void **list) { | 83 inline void *FL_Pop(void **list) { |
| 84 return SLL_Pop(list); | 84 return SLL_Pop(list); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Removes |N| elements from a linked list to which |head| points. | 87 // Removes |N| elements from a linked list to which |head| points. |
| 88 // |head| will be modified to point to the new |head|. |start| and | 88 // |head| will be modified to point to the new |head|. |start| and |
| 89 // |end| will point to the first and last nodes of the range. Note | 89 // |end| will point to the first and last nodes of the range. Note |
| 90 // that |end| will point to NULL after this function is called. | 90 // that |end| will point to NULL after this function is called. |
| 91 inline void FL_PopRange(void **head, int n, void **start, void **end) { | 91 inline void FL_PopRange(void **head, int n, void **start, void **end) { |
| 92 SLL_PopRange(head, n, start, end); | 92 SLL_PopRange(head, n, start, end); |
| 93 } | 93 } |
| 94 | 94 |
| 95 inline void FL_PushRange(void **head, void *start, void *end) { | 95 inline void FL_PushRange(void **head, void *start, void *end) { |
| 96 SLL_PushRange(head,start,end); | 96 SLL_PushRange(head,start,end); |
| 97 } | 97 } |
| 98 | 98 |
| 99 inline size_t FL_Size(void *head) { | 99 inline size_t FL_Size(void *head) { |
| 100 return SLL_Size(head); | 100 return SLL_Size(head); |
| 101 } | 101 } |
| 102 | 102 |
| 103 #endif // TCMALLOC_USE_DOUBLYLINKED_FREELIST | 103 #endif // TCMALLOC_USE_DOUBLYLINKED_FREELIST |
| 104 | 104 |
| 105 } // namespace tcmalloc | 105 } // namespace tcmalloc |
| 106 | 106 |
| 107 #endif // TCMALLOC_FREE_LIST_H_ | 107 #endif // TCMALLOC_FREE_LIST_H_ |
| OLD | NEW |