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

Function GDKmallocated to return size of allocated buffer.


diffs (41 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
@@ -291,6 +291,7 @@ ATOMIC_FLAG GDKlocklistlock;
 ATOMIC_TYPE GDKlocksleepcnt;
 void GDKlockstatistics(int);
 void *GDKmalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__alloc_size__(1))) __attribute__((__warn_unused_result__));
+size_t GDKmallocated(const void *s);
 size_t GDKmem_cursize(void);
 gdk_return GDKmergeidx(BAT *b, BAT **a, int n_ar);
 void *GDKmmap(const char *path, int mode, size_t len) 
__attribute__((__warn_unused_result__));
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2038,6 +2038,15 @@ GDKrealloc(void *s, size_t size)
        return s;
 }
 
+/* return how much memory was allocated; the argument must be a value
+ * returned by GDKmalloc, GDKzalloc, GDKrealloc, GDKstrdup, or
+ * GDKstrndup */
+size_t
+GDKmallocated(const void *s)
+{
+       return ((const size_t *) s)[-1]; /* how much allocated last */
+}
+
 void
 GDKsetmallocsuccesscount(lng count)
 {
diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -98,6 +98,7 @@ gdk_export str GDKstrdup(const char *s)
 gdk_export str GDKstrndup(const char *s, size_t n)
        __attribute__((__malloc__))
        __attribute__((__warn_unused_result__));
+gdk_export size_t GDKmallocated(const void *s);
 
 gdk_export void MT_init(void); /*  init the package. */
 struct opt;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to