{"id":2404,"date":"2017-12-19T09:41:38","date_gmt":"2017-12-19T01:41:38","guid":{"rendered":"https:\/\/www.csslayer.info\/wordpress\/?p=2404"},"modified":"2017-12-19T09:41:38","modified_gmt":"2017-12-19T01:41:38","slug":"what-would-happen-when-you-debug-a-memory-leak-in-an-outdated-language","status":"publish","type":"post","link":"https:\/\/www.csslayer.info\/wordpress\/linux\/what-would-happen-when-you-debug-a-memory-leak-in-an-outdated-language\/","title":{"rendered":"\u5f53\u4f60 Debug \u4e00\u95e8\u8fc7\u6c14\u8bed\u8a00\u751f\u6210\u7684\u4ee3\u7801\u91cc\u9762\u4ea7\u751f\u7684 memory leak \u65f6\u4f1a\u53d1\u751f\u4ec0\u4e48 (a.k.a. \u4e0d\u8981\u4fee\u6539 vala \u8fd4\u56de\u7684 strv \u7684 length\uff09"},"content":{"rendered":"<p>\uff08\u4f1a\u88ab\u5199\u6210 blog \u53d1\u51fa\u6765\u3002\uff09<\/p>\n<p>\u76f4\u63a5\u4e0a\u4e00\u6bb5\u4ee3\u7801\u3002<\/p>\n<pre>var array = elements.to_array ();\r\narray.length = -1;\r\nreturn \"(\" + string.joinv (\" \", array) + \")\";<\/pre>\n<p>\u63d0\u95ee\uff0c\u8fd9\u6bb5\u4ee3\u7801\u6709\u4ec0\u4e48\u95ee\u9898\uff1f<\/p>\n<p>\u5b83\u4f1a\u751f\u6210\u8fd9\u6837\u7684\u4ee3\u7801\u3002<\/p>\n<pre>_tmp32_ = gee_collection_to_array ((GeeCollection*) _tmp30_, &amp;_tmp31_);\r\narray = _tmp32_;\r\narray_length1 = _tmp31_;\r\n_array_size_ = array_length1;\r\narray_length1 = -1;\r\n_tmp33_ = array_length1;\r\n_tmp34_ = array;\r\n_tmp34__length1 = array_length1;\r\n_tmp35_ = _vala_g_strjoinv (\" \", _tmp34_, _tmp34__length1);\r\n_tmp36_ = _tmp35_;\r\n_tmp37_ = g_strconcat (\"(\", _tmp36_, NULL);\r\n_tmp38_ = _tmp37_;\r\n_tmp39_ = g_strconcat (_tmp38_, \")\", NULL);\r\n_tmp40_ = _tmp39_;\r\n_g_free0 (_tmp38_);\r\n_g_free0 (_tmp36_);\r\nresult = _tmp40_;\r\narray = (_vala_array_free (array, array_length1, (GDestroyNotify) g_free), NULL);\r\n_g_object_unref0 (elements);\r\n_g_free0 (_base);\r\n_g_free0 (_tmp0_);\r\nreturn result;<\/pre>\n<p>\u90a3\u4e48\u4f60\u518d\u731c\u731c\uff1f\u7ed9\u4f60\u70b9\u63d0\u793a\u3002<\/p>\n<pre>static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {\r\n    if ((array != NULL) &amp;&amp; (destroy_func != NULL)) {\r\n        int i;\r\n        for (i = 0; i &lt; array_length; i = i + 1) {\r\n            if (((gpointer*) array)[i] != NULL) {\r\n                destroy_func (((gpointer*) array)[i]);\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\r\nstatic void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {\r\n    _vala_array_destroy (array, array_length, destroy_func);\r\n    g_free (array);\r\n}<\/pre>\n<p>\u00b4_&gt;` strv \u662f\u4e00\u4e2a\u4e0d\u80fd\u6539\u53d8\u5927\u5c0f\u7684 array \u2026\u2026\u90a3\u4e48\u4f60\u6539\u4e86\u5b83\u7684\u5927\u5c0f\u2026\u2026free \u5b83\u7684\u51fd\u6570\u6ca1\u6cd5\u6b63\u5e38\u5de5\u4f5c\u2026\u2026\u7136\u540e\u5c31\u4f1a\u9020\u6210 leak \u2026\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uff08\u4f1a\u88ab\u5199\u6210 blog \u53d1\u51fa\u6765\u3002\uff09 \u76f4\u63a5\u4e0a\u4e00\u6bb5\u4ee3\u7801\u3002 var array = elements.to_array (); array.length = -1; return &#8220;(&#8221; + string.joinv (&#8221; &#8220;, array) + &#8220;)&#8221;; \u63d0\u95ee\uff0c\u8fd9\u6bb5\u4ee3\u7801\u6709\u4ec0\u4e48\u95ee\u9898\uff1f \u5b83\u4f1a\u751f\u6210\u8fd9\u6837\u7684\u4ee3\u7801\u3002 _tmp32_ = gee_collection_to_array ((GeeCollection*) _tmp30_, &amp;_tmp31_); array = _tmp32_; array_length1 = _tmp31_; _array_size_ = array_length1; array_length1 = &hellip; <a href=\"https:\/\/www.csslayer.info\/wordpress\/linux\/what-would-happen-when-you-debug-a-memory-leak-in-an-outdated-language\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[240,239],"class_list":["post-2404","post","type-post","status-publish","format-standard","hentry","category-linux","tag-glib","tag-vala"],"_links":{"self":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/comments?post=2404"}],"version-history":[{"count":2,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2404\/revisions"}],"predecessor-version":[{"id":2429,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2404\/revisions\/2429"}],"wp:attachment":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/media?parent=2404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/categories?post=2404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/tags?post=2404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}