[gjs/299-can-not-access-gobject-properties-of-classes-without-gi-information] jsapi-util: add GjsAutoFree



commit 1183c8ecbb813ec955be0b14b1baba97d509a3f6
Author: Juan Pablo Ugarte <ugarte endlessm com>
Date:   Thu Jan 16 19:08:35 2020 -0300

    jsapi-util: add GjsAutoFree
    
    Add convenience template to autofree memory with g_free()

 gjs/jsapi-util.h | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 06f57b5b..81bfc7da 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -64,6 +64,9 @@ struct GjsAutoPointer : std::unique_ptr<T, decltype(free_func)> {
     }
 };
 
+template <typename T>
+using GjsAutoFree = GjsAutoPointer<T, void, g_free>;
+
 struct GjsAutoCharFuncs {
     static char* dup(char* str) { return g_strdup(str); }
     static void free(char* str) { g_free(str); }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]