[gjs/gnome-3-34] jsapi-util: add GjsAutoFree



commit 1fdec46a35ef4814ad8583424b86d88ec554a0c4
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]