Changeset 20020 in webkit for trunk/JavaScriptCore/wtf/FastMalloc.cpp
- Timestamp:
- Mar 7, 2007, 8:34:56 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/FastMalloc.cpp
r20019 r20020 79 79 namespace WTF { 80 80 81 static bool isForbidden = false; 81 static pthread_key_t isForbiddenKey; 82 static pthread_once_t isForbiddenKeyOnce = PTHREAD_ONCE_INIT; 83 static void initializeIsForbiddenKey() 84 { 85 pthread_key_create(&isForbiddenKey, 0); 86 } 87 88 static bool isForbidden() 89 { 90 pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey); 91 return !!pthread_getspecific(isForbiddenKey); 92 } 93 82 94 void fastMallocForbid() 83 95 { 84 isForbidden = true; 96 pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey); 97 pthread_setspecific(isForbiddenKey, &isForbiddenKey); 85 98 } 86 99 87 100 void fastMallocAllow() 88 101 { 89 isForbidden = false; 102 pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey); 103 pthread_setspecific(isForbiddenKey, 0); 90 104 } 91 105 … … 104 118 void *fastMalloc(size_t n) 105 119 { 106 ASSERT(!isForbidden );120 ASSERT(!isForbidden()); 107 121 return malloc(n); 108 122 } … … 110 124 void *fastCalloc(size_t n_elements, size_t element_size) 111 125 { 112 ASSERT(!isForbidden );126 ASSERT(!isForbidden()); 113 127 return calloc(n_elements, element_size); 114 128 } … … 116 130 void fastFree(void* p) 117 131 { 118 ASSERT(!isForbidden );132 ASSERT(!isForbidden()); 119 133 free(p); 120 134 } … … 122 136 void *fastRealloc(void* p, size_t n) 123 137 { 124 ASSERT(!isForbidden );138 ASSERT(!isForbidden()); 125 139 return realloc(p, n); 126 140 } … … 1904 1918 #ifdef WTF_CHANGES 1905 1919 ASSERT(isMultiThreaded || pthread_main_np()); 1906 ASSERT(!isForbidden );1920 ASSERT(!isForbidden()); 1907 1921 #endif 1908 1922
Note:
See TracChangeset
for help on using the changeset viewer.