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



commit 1acf25089ee6d8bfeb5e52ad6a5651c123823658
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 65d71e73..3d399ce3 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -74,6 +74,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]