diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-10-21 04:55:41 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-11-05 17:36:17 +0000 |
commit | 174df99ffa53f1091589eaa4fa0c16cdd55a9326 (patch) | |
tree | 3a60d45615f18beed98a9b08267c28ed7e05dd5f /ta | |
parent | 3a8b107f6216b38a151d5ca1e9d4f2727e3418f5 (diff) | |
download | mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.bz2 mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.xz |
ALL: use new mp_thread abstraction
Diffstat (limited to 'ta')
-rw-r--r-- | ta/ta.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -265,9 +265,9 @@ void ta_set_destructor(void *ptr, void (*destructor)(void *)) #if TA_MEMORY_DEBUGGING -#include <pthread.h> +#include "osdep/threads.h" -static pthread_mutex_t ta_dbg_mutex = PTHREAD_MUTEX_INITIALIZER; +static mp_static_mutex ta_dbg_mutex = MP_STATIC_MUTEX_INITIALIZER; static bool enable_leak_check; // pretty much constant static struct ta_header leak_node; static char allocation_is_string; @@ -276,12 +276,12 @@ static void ta_dbg_add(struct ta_header *h) { h->canary = CANARY; if (enable_leak_check) { - pthread_mutex_lock(&ta_dbg_mutex); + mp_mutex_lock(&ta_dbg_mutex); h->leak_next = &leak_node; h->leak_prev = leak_node.leak_prev; leak_node.leak_prev->leak_next = h; leak_node.leak_prev = h; - pthread_mutex_unlock(&ta_dbg_mutex); + mp_mutex_unlock(&ta_dbg_mutex); } } @@ -300,10 +300,10 @@ static void ta_dbg_remove(struct ta_header *h) { ta_dbg_check_header(h); if (h->leak_next) { // assume checking for !=NULL invariant ok without lock - pthread_mutex_lock(&ta_dbg_mutex); + mp_mutex_lock(&ta_dbg_mutex); h->leak_next->leak_prev = h->leak_prev; h->leak_prev->leak_next = h->leak_next; - pthread_mutex_unlock(&ta_dbg_mutex); + mp_mutex_unlock(&ta_dbg_mutex); h->leak_next = h->leak_prev = NULL; } h->canary = 0; @@ -319,7 +319,7 @@ static size_t get_children_size(struct ta_header *h) static void print_leak_report(void) { - pthread_mutex_lock(&ta_dbg_mutex); + mp_mutex_lock(&ta_dbg_mutex); if (leak_node.leak_next && leak_node.leak_next != &leak_node) { size_t size = 0; size_t num_blocks = 0; @@ -354,19 +354,19 @@ static void print_leak_report(void) } fprintf(stderr, "%zu bytes in %zu blocks.\n", size, num_blocks); } - pthread_mutex_unlock(&ta_dbg_mutex); + mp_mutex_unlock(&ta_dbg_mutex); } void ta_enable_leak_report(void) { - pthread_mutex_lock(&ta_dbg_mutex); + mp_mutex_lock(&ta_dbg_mutex); enable_leak_check = true; if (!leak_node.leak_prev && !leak_node.leak_next) { leak_node.leak_prev = &leak_node; leak_node.leak_next = &leak_node; atexit(print_leak_report); } - pthread_mutex_unlock(&ta_dbg_mutex); + mp_mutex_unlock(&ta_dbg_mutex); } /* Set a (static) string that will be printed if the memory allocation in ptr |