]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Avoid ref/unref of AttributeCache when calling get_ccode_attribute()
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 23 Apr 2018 15:09:00 +0000 (17:09 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 23 Apr 2018 17:19:33 +0000 (19:19 +0200)
codegen/valaccode.vala

index 0305f2ec55fcab391c56ce2dd33d46be696a86be..82b4699e7d7495fdaa8761d15f7a506075861949 100644 (file)
 namespace Vala {
        static int? ccode_attribute_cache_index = null;
 
-       static CCodeAttribute get_ccode_attribute (CodeNode node) {
+       static unowned CCodeAttribute get_ccode_attribute (CodeNode node) {
                if (ccode_attribute_cache_index == null) {
                        ccode_attribute_cache_index = CodeNode.get_attribute_cache_index ();
                }
 
-               var attr = node.get_attribute_cache (ccode_attribute_cache_index);
+               unowned AttributeCache? attr = node.get_attribute_cache (ccode_attribute_cache_index);
                if (attr == null) {
-                       attr = new CCodeAttribute (node);
-                       node.set_attribute_cache (ccode_attribute_cache_index, attr);
+                       var new_attr = new CCodeAttribute (node);
+                       node.set_attribute_cache (ccode_attribute_cache_index, new_attr);
+                       attr = new_attr;
                }
                return (CCodeAttribute) attr;
        }