| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "wtf/Assertions.h" | 22 #include "wtf/Assertions.h" |
| 23 | 23 |
| 24 #if ENABLE(ASSERT) | 24 #if ENABLE(ASSERT) |
| 25 #include "wtf/Atomics.h" | 25 #include "wtf/Atomics.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace WTF { | 28 namespace WTF { |
| 29 | 29 |
| 30 #if !ENABLE(ASSERT) | 30 #if !ENABLE(ASSERT) |
| 31 | 31 |
| 32 RefCountedLeakCounter::RefCountedLeakCounter(const char*) { } | 32 RefCountedLeakCounter::RefCountedLeakCounter(const char*) {} |
| 33 RefCountedLeakCounter::~RefCountedLeakCounter() { } | 33 RefCountedLeakCounter::~RefCountedLeakCounter() {} |
| 34 | 34 |
| 35 void RefCountedLeakCounter::increment() { } | 35 void RefCountedLeakCounter::increment() {} |
| 36 void RefCountedLeakCounter::decrement() { } | 36 void RefCountedLeakCounter::decrement() {} |
| 37 | 37 |
| 38 #else | 38 #else |
| 39 | 39 |
| 40 #define LOG_CHANNEL_PREFIX Log | 40 #define LOG_CHANNEL_PREFIX Log |
| 41 static WTFLogChannel LogRefCountedLeaks = { WTFLogChannelOn }; | 41 static WTFLogChannel LogRefCountedLeaks = {WTFLogChannelOn}; |
| 42 | 42 |
| 43 RefCountedLeakCounter::RefCountedLeakCounter(const char* description) | 43 RefCountedLeakCounter::RefCountedLeakCounter(const char* description) |
| 44 : m_description(description) | 44 : m_description(description) {} |
| 45 { | 45 |
| 46 RefCountedLeakCounter::~RefCountedLeakCounter() { |
| 47 if (!m_count) |
| 48 return; |
| 49 |
| 50 WTF_LOG(RefCountedLeaks, "LEAK: %u %s", m_count, m_description); |
| 46 } | 51 } |
| 47 | 52 |
| 48 RefCountedLeakCounter::~RefCountedLeakCounter() | 53 void RefCountedLeakCounter::increment() { |
| 49 { | 54 atomicIncrement(&m_count); |
| 50 if (!m_count) | |
| 51 return; | |
| 52 | |
| 53 WTF_LOG(RefCountedLeaks, "LEAK: %u %s", m_count, m_description); | |
| 54 } | 55 } |
| 55 | 56 |
| 56 void RefCountedLeakCounter::increment() | 57 void RefCountedLeakCounter::decrement() { |
| 57 { | 58 atomicDecrement(&m_count); |
| 58 atomicIncrement(&m_count); | |
| 59 } | |
| 60 | |
| 61 void RefCountedLeakCounter::decrement() | |
| 62 { | |
| 63 atomicDecrement(&m_count); | |
| 64 } | 59 } |
| 65 | 60 |
| 66 #endif | 61 #endif |
| 67 | 62 |
| 68 } // namespace WTF | 63 } // namespace WTF |
| OLD | NEW |