Changeset: c5e8dedf544b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c5e8dedf544b
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk.h
        gdk/gdk_utils.c
Branch: Dec2025
Log Message:

Use locks when printing allocator info.


diffs (49 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -568,7 +568,7 @@ void ma_destroy(allocator *sa);
 void ma_free(allocator *sa, void *);
 exception_buffer *ma_get_eb(allocator *sa) __attribute__((__pure__));
 allocator *ma_get_parent(const allocator *sa);
-int ma_info(const allocator *sa, char *buf, size_t buflen, const char *pref);
+int ma_info(allocator *sa, char *buf, size_t buflen, const char *pref);
 const char *ma_name(allocator *sa);
 allocator_state ma_open(allocator *sa);
 void *ma_realloc(allocator *sa, void *ptr, size_t sz, size_t osz);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1774,7 +1774,7 @@ gdk_export void ma_free(allocator *sa, v
 gdk_export exception_buffer *ma_get_eb(allocator *sa)
        __attribute__((__pure__));
 
-gdk_export int ma_info(const allocator *sa, char *buf, size_t buflen, const 
char *pref);
+gdk_export int ma_info(allocator *sa, char *buf, size_t buflen, const char 
*pref);
 
 #define MA_NEW( sa, type )                             ((type*)ma_alloc( sa, 
sizeof(type)))
 #define MA_ZNEW( sa, type )                            ((type*)ma_zalloc( sa, 
sizeof(type)))
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2659,11 +2659,12 @@ ma_get_parent(const allocator *a)
 }
 
 int
-ma_info(const allocator *a, char *buf, size_t bufsize, const char *pref)
+ma_info(allocator *a, char *buf, size_t bufsize, const char *pref)
 {
        int pos = 0;
        buf[0] = 0;
        if (a != NULL) {
+               COND_LOCK_ALLOCATOR(a);
                pos = snprintf(buf, bufsize, "%s%s: used %zu%s, usedmem %zu%s",
                               pref ? pref : "", a->name,
                               a->used, humansize(a->used, (char[24]){0}, 24),
@@ -2680,6 +2681,7 @@ ma_info(const allocator *a, char *buf, s
                if (a->refcount > 0 && (size_t) pos < bufsize)
                        pos += snprintf(buf + pos, bufsize - pos,
                                        ", refcount %d", a->refcount);
+               COND_UNLOCK_ALLOCATOR(a);
        }
        return pos;
 }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to