[gjs: 1/6] maint: Use GjsAutoChar::out() for out-pointers




commit 9d3d3c29f8ff537ecef0fbbf494fba22d633a266
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Oct 9 18:15:57 2021 -0700

    maint: Use GjsAutoChar::out() for out-pointers
    
    Fix a few more instances of the pattern already fixed in 82cd3939.

 gjs/context.cpp | 5 ++---
 gjs/module.cpp  | 6 ++----
 2 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 9a75d596..04736f30 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -1362,14 +1362,13 @@ gjs_context_eval_file(GjsContext    *js_context,
                       int           *exit_status_p,
                       GError       **error)
 {
-    char *script;
+    GjsAutoChar script;
     size_t script_len;
     GjsAutoUnref<GFile> file = g_file_new_for_commandline_arg(filename);
 
-    if (!g_file_load_contents(file, nullptr, &script, &script_len, nullptr,
+    if (!g_file_load_contents(file, nullptr, script.out(), &script_len, nullptr,
                               error))
         return false;
-    GjsAutoChar script_ref = script;
 
     return gjs_context_eval(js_context, script, script_len, filename,
                             exit_status_p, error);
diff --git a/gjs/module.cpp b/gjs/module.cpp
index c92bd05f..1ff806f9 100644
--- a/gjs/module.cpp
+++ b/gjs/module.cpp
@@ -144,14 +144,12 @@ class GjsScriptModule {
                 GFile           *file)
     {
         GError *error = nullptr;
-        char *unowned_script;
+        GjsAutoChar script;
         size_t script_len = 0;
 
-        if (!(g_file_load_contents(file, nullptr, &unowned_script, &script_len,
+        if (!(g_file_load_contents(file, nullptr, script.out(), &script_len,
                                    nullptr, &error)))
             return gjs_throw_gerror_message(cx, error);
-
-        GjsAutoChar script = unowned_script;  /* steals ownership */
         g_assert(script);
 
         GjsAutoChar full_path = g_file_get_parse_name(file);


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