static struct list_head list = { &list, &list };
-pipe_static_mutex(list_mutex);
+static mtx_t list_mutex = _MTX_INITIALIZER_NP;
static unsigned long last_no = 0;
-static INLINE struct debug_memory_header *
+static inline struct debug_memory_header *
header_from_data(void *data)
{
if(data)
return NULL;
}
-static INLINE void *
+static inline void *
data_from_header(struct debug_memory_header *hdr)
{
if(hdr)
return NULL;
}
-static INLINE struct debug_memory_footer *
+static inline struct debug_memory_footer *
footer_from_header(struct debug_memory_header *hdr)
{
if(hdr)
struct debug_memory_footer *ftr;
hdr = os_malloc(sizeof(*hdr) + size + sizeof(*ftr));
- if(!hdr) {
+ if (!hdr) {
debug_printf("%s:%u:%s: out of memory when trying to allocate %lu bytes\n",
file, line, function,
(long unsigned)size);
ftr = footer_from_header(hdr);
ftr->magic = DEBUG_MEMORY_MAGIC;
- pipe_mutex_lock(list_mutex);
+ mtx_lock(&list_mutex);
LIST_ADDTAIL(&hdr->head, &list);
- pipe_mutex_unlock(list_mutex);
+ mtx_unlock(&list_mutex);
return data_from_header(hdr);
}
struct debug_memory_header *hdr;
struct debug_memory_footer *ftr;
- if(!ptr)
+ if (!ptr)
return;
hdr = header_from_data(ptr);
/* set freed memory to special value */
memset(ptr, DEBUG_FREED_BYTE, hdr->size);
#else
- pipe_mutex_lock(list_mutex);
+ mtx_lock(&list_mutex);
LIST_DEL(&hdr->head);
- pipe_mutex_unlock(list_mutex);
+ mtx_unlock(&list_mutex);
hdr->magic = 0;
ftr->magic = 0;
size_t count, size_t size )
{
void *ptr = debug_malloc( file, line, function, count * size );
- if( ptr )
+ if (ptr)
memset( ptr, 0, count * size );
return ptr;
}
struct debug_memory_footer *old_ftr, *new_ftr;
void *new_ptr;
- if(!old_ptr)
+ if (!old_ptr)
return debug_malloc( file, line, function, new_size );
if(!new_size) {
/* alloc new */
new_hdr = os_malloc(sizeof(*new_hdr) + new_size + sizeof(*new_ftr));
- if(!new_hdr) {
+ if (!new_hdr) {
debug_printf("%s:%u:%s: out of memory when trying to allocate %lu bytes\n",
file, line, function,
(long unsigned)new_size);
new_ftr = footer_from_header(new_hdr);
new_ftr->magic = DEBUG_MEMORY_MAGIC;
- pipe_mutex_lock(list_mutex);
+ mtx_lock(&list_mutex);
LIST_REPLACE(&old_hdr->head, &new_hdr->head);
- pipe_mutex_unlock(list_mutex);
+ mtx_unlock(&list_mutex);
/* copy data */
new_ptr = data_from_header(new_hdr);