Skip to content

Commit a3e1745

Browse files
committed
Improved refcount debugging by printing function and line information while *destroy as well
1 parent f703d01 commit a3e1745

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/rd.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@
4444
#ifndef _POSIX_C_SOURCE
4545
#define _POSIX_C_SOURCE 200809L /* for timespec on solaris */
4646
#endif
47-
#else
48-
#ifndef _CRT_RAND_S
49-
#define _CRT_RAND_S /* for rand_s() on MSVC. It needs to be defined before \
50-
* including <stdlib.h>. */
51-
#endif
5247
#endif
5348

5449
#include <stdio.h>
@@ -417,14 +412,17 @@ static RD_INLINE RD_UNUSED int rd_refcnt_get(rd_refcnt_t *R) {
417412
rd_refcnt_get(R), (R), WHAT, __FUNCTION__, __LINE__), \
418413
rd_refcnt_sub0(R))
419414

420-
#define rd_refcnt_sub(R) \
415+
#define rd_refcnt_sub_fl(FUNC, LINE, R) \
421416
(fprintf(stderr, "REFCNT DEBUG: %-35s %d -1: %16p: %s:%d\n", #R, \
422-
rd_refcnt_get(R), (R), __FUNCTION__, __LINE__), \
417+
rd_refcnt_get(R), (R), (FUNC), (LINE)), \
423418
rd_refcnt_sub0(R))
424419

420+
#define rd_refcnt_sub(R) rd_refcnt_sub_fl(__FUNCTION__, __LINE__, R)
421+
425422
#else
426423
#define rd_refcnt_add_fl(FUNC, LINE, R) rd_refcnt_add0(R)
427424
#define rd_refcnt_add(R) rd_refcnt_add0(R)
425+
#define rd_refcnt_sub_fl(FUNC, LINE, R) rd_refcnt_sub0(R)
428426
#define rd_refcnt_sub(R) rd_refcnt_sub0(R)
429427
#endif
430428

0 commit comments

Comments
 (0)