{"id":868,"date":"2026-05-15T15:24:34","date_gmt":"2026-05-15T07:24:34","guid":{"rendered":"https:\/\/hsiang.cc\/?p=868"},"modified":"2026-05-13T15:30:59","modified_gmt":"2026-05-13T07:30:59","slug":"c-%e7%9a%84%e9%82%a3%e4%ba%9b%e7%9c%89%e8%a7%92malloc-%e4%b9%8b%e5%be%8c%e4%b8%80%e5%ae%9a%e8%a6%81%e6%aa%a2%e6%9f%a5-%e8%a8%98%e6%86%b6%e9%ab%94%e9%85%8d%e7%bd%ae%e7%9a%84%e9%98%b2","status":"publish","type":"post","link":"https:\/\/hsiang.cc\/?p=868","title":{"rendered":"[C \u7684\u90a3\u4e9b\u7709\u89d2]malloc \u4e4b\u5f8c\u4e00\u5b9a\u8981\u6aa2\u67e5 \u2014 \u8a18\u61b6\u9ad4\u914d\u7f6e\u7684\u9632\u79a6\u6027\u5beb\u6cd5"},"content":{"rendered":"<p>\u5e73\u5e38\u5728\u5d4c\u5165\u5f0f\u7cfb\u7d71\u4e0a\u7528 <code>malloc<\/code>\uff0c<br \/>\n\u5beb\u5b8c\u4e4b\u5f8c\u89ba\u5f97\u5f88\u723d\uff0c\u52d5\u614b\u914d\u7f6e\u8a18\u61b6\u9ad4\uff0c\u597d\u50cf\u5f88\u53b2\u5bb3\u3002<\/p>\n<pre><code class=\"language-c\">uint8_t *buf = malloc(1024);\nmemset(buf, 0, 1024);\n\/\/ \u958b\u59cb\u7528 buf...<\/code><\/pre>\n<p>\u6709\u4e00\u6b21\u670b\u53cb\u770b\u4e86\u4e00\u773c\u554f\u6211\uff1a\u300c<code>malloc<\/code> \u5931\u6557\u600e\u9ebc\u8fa6\uff1f\u300d<\/p>\n<p>\u6211\u8aaa\uff1a\u300c\u6703\u5931\u6557\u55ce\uff1f\u8a18\u61b6\u9ad4\u61c9\u8a72\u5920\u5427\uff1f\u300d<\/p>\n<p>\u4ed6\u8aaa\uff1a\u300c\u5d4c\u5165\u5f0f\u7684 heap \u5c31\u90a3\u9ebc\u5927\uff0c\u4f60\u78ba\u5b9a\u55ce\uff1f\u300d<\/p>\n<p>\u6211 ........ \u7576\u7136\u4e0d\u662f\u5f88\u78ba\u5b9a\u3002<\/p>\n<p><!--more--><\/p>\n<hr \/>\n<h2>malloc \u53ef\u80fd\u6703\u5931\u6557<\/h2>\n<p>\u9019\u4ef6\u4e8b\u5f88\u591a\u4eba\u77e5\u9053\uff0c\u4f46\u5beb\u7a0b\u5f0f\u7684\u7576\u4e0b\u5e38\u5e38\u53c8\u795e\u5947\u7684\u5fd8\u8a18\u3002<\/p>\n<p><code>malloc<\/code> \u5728\u4ee5\u4e0b\u60c5\u6cc1\u6703\u5931\u6557\uff0c\u56de\u50b3 <code>NULL<\/code>\uff1a<\/p>\n<ul>\n<li><strong>heap \u7a7a\u9593\u4e0d\u8db3<\/strong> \u2014 \u5d4c\u5165\u5f0f\u7cfb\u7d71\u7684 heap \u901a\u5e38\u53ea\u6709\u5e7e KB \u5230\u5e7e\u5341 KB<\/li>\n<li><strong>heap \u788e\u7247\u5316<\/strong> \u2014 \u6709\u8db3\u5920\u7684\u7e3d\u7a7a\u9593\uff0c\u4f46\u6c92\u6709\u9023\u7e8c\u7684\u5927\u584a\u53ef\u4ee5\u5206\u914d<\/li>\n<li><strong>\u8acb\u6c42\u592a\u5927<\/strong> \u2014 \u4e00\u6b21\u8981\u6c42\u8d85\u904e\u53ef\u7528\u7a7a\u9593<\/li>\n<\/ul>\n<pre><code class=\"language-c\">\/\/ malloc \u5931\u6557\u6642\u56de\u50b3 NULL\nuint8_t *buf = malloc(1024);\n\n\/\/ \u274c \u6c92\u6709\u6aa2\u67e5\uff0c\u76f4\u63a5\u7528\nmemset(buf, 0, 1024);  \/\/ buf \u662f NULL\uff0c\u9019\u88e1\u76f4\u63a5 crash<\/code><\/pre>\n<p>\u5728 PC \u4e0a\uff0c\u8a18\u61b6\u9ad4\u901a\u5e38\u5f88\u5145\u88d5\uff0c<br \/>\n<code>malloc<\/code> \u5931\u6557\u7684\u6a5f\u7387\u5f88\u4f4e\uff0c<br \/>\n\u6240\u4ee5\u5f88\u591a\u4eba\u990a\u6210\u4e86\u4e0d\u6aa2\u67e5\u7684\u7fd2\u6163\u3002<\/p>\n<p>\u5e36\u5230\u5d4c\u5165\u5f0f\uff0c\u5c31\u8e29\u5751\u4e86\u3002<\/p>\n<hr \/>\n<h2>\u57fa\u672c\u7684\u9632\u79a6\u5beb\u6cd5<\/h2>\n<pre><code class=\"language-c\">uint8_t *buf = malloc(1024);\nif (buf == NULL) {\n    \/\/ \u914d\u7f6e\u5931\u6557\uff0c\u8655\u7406\u932f\u8aa4\n    LOG_ERROR(&quot;malloc failed, size=%d&quot;, 1024);\n    return ERR_NO_MEMORY;\n}\n\n\/\/ \u78ba\u8a8d buf \u6709\u6548\u624d\u7e7c\u7e8c\nmemset(buf, 0, 1024);\n\/\/ ... \u4f7f\u7528 buf ...<\/code><\/pre>\n<p>\u5c31\u9019\u6a23\uff0c\u591a\u4e09\u884c\uff0c\u4f46\u53ef\u4ee5\u6551\u4f60\u5f88\u591a\u6b21\u3002<\/p>\n<hr \/>\n<h2>\u5305\u88dd\u6210\u5b89\u5168\u7248\u672c<\/h2>\n<p>\u6bcf\u6b21 <code>malloc<\/code> \u90fd\u8981\u5beb\u4e00\u6a23\u7684\u6aa2\u67e5\uff0c\u5f88\u56c9\u55e6\u3002<br \/>\n\u6211\u7fd2\u6163\u5305\u4e00\u500b wrapper\uff1a<\/p>\n<pre><code class=\"language-c\">\/\/ safe_malloc.h\n#include &lt;stdlib.h&gt;\n#include &lt;string.h&gt;\n\n\/**\n * \u914d\u7f6e\u8a18\u61b6\u9ad4\u4e26\u6e05\u96f6\uff0c\u5931\u6557\u6642\u56de\u50b3 NULL\n *\/\nstatic inline void *safe_malloc(size_t size) {\n    if (size == 0) {\n        return NULL;\n    }\n    void *ptr = malloc(size);\n    if (ptr != NULL) {\n        memset(ptr, 0, size);  \/\/ \u9806\u4fbf\u6e05\u96f6\uff0c\u907f\u514d\u5783\u573e\u503c\n    }\n    return ptr;\n}\n\n\/**\n * \u914d\u7f6e\u8a18\u61b6\u9ad4\uff0c\u5931\u6557\u6642\u5370 log \u4e26\u56de\u50b3 NULL\n *\/\n#define MALLOC_LOG(size)  malloc_with_log((size), __FILE__, __LINE__)\n\nstatic inline void *malloc_with_log(size_t size,\n                                     const char *file,\n                                     int line) {\n    void *ptr = malloc(size);\n    if (ptr == NULL) {\n        \/\/ \u4f60\u7684 log \u51fd\u5f0f\n        log_error(&quot;[%s:%d] malloc failed, size=%zu&quot;, file, line, size);\n    }\n    return ptr;\n}<\/code><\/pre>\n<p>\u4f7f\u7528\uff1a<\/p>\n<pre><code class=\"language-c\">uint8_t *buf = safe_malloc(1024);\nif (buf == NULL) {\n    return ERR_NO_MEMORY;\n}<\/code><\/pre>\n<p>\u6216\u662f\u60f3\u8981\u81ea\u52d5\u5e36 log\uff1a<\/p>\n<pre><code class=\"language-c\">uint8_t *buf = MALLOC_LOG(1024);\nif (buf == NULL) {\n    return ERR_NO_MEMORY;\n}<\/code><\/pre>\n<hr \/>\n<h2>calloc vs malloc<\/h2>\n<p>\u5f88\u591a\u4eba\u53ea\u77e5\u9053 <code>malloc<\/code>\uff0c\u4f46 <code>calloc<\/code> \u5728\u67d0\u4e9b\u60c5\u6cc1\u66f4\u597d\u7528\uff1a<\/p>\n<pre><code class=\"language-c\">\/\/ malloc\uff1a\u914d\u7f6e\u8a18\u61b6\u9ad4\uff0c\u5167\u5bb9\u662f\u5783\u573e\u503c\nuint8_t *buf = malloc(1024);\n\n\/\/ calloc\uff1a\u914d\u7f6e\u8a18\u61b6\u9ad4\uff0c\u5167\u5bb9\u6e05\u96f6\n\/\/ calloc(\u5143\u7d20\u6578\u91cf, \u6bcf\u500b\u5143\u7d20\u5927\u5c0f)\nuint8_t *buf = calloc(1024, sizeof(uint8_t));<\/code><\/pre>\n<p><code>calloc<\/code> \u5e6b\u4f60\u505a\u4e86\u6e05\u96f6\uff0c\u4e0d\u9700\u8981\u518d <code>memset<\/code>\u3002<\/p>\n<p>\u53e6\u5916\uff0c<code>calloc<\/code> \u5728\u8a08\u7b97\u7e3d\u5927\u5c0f\u7684\u6642\u5019\uff0c<br \/>\n\u6703\u5e6b\u4f60\u505a\u6ea2\u4f4d\u6aa2\u67e5\uff1a<\/p>\n<pre><code class=\"language-c\">\/\/ \u5982\u679c count * size \u6ea2\u4f4d\uff0cmalloc \u53ef\u80fd\u914d\u7f6e\u5230\u932f\u8aa4\u5927\u5c0f\u7684\u8a18\u61b6\u9ad4\nsize_t count = 1000000;\nsize_t size  = 10000;\nuint8_t *buf = malloc(count * size);  \/\/ count * size \u53ef\u80fd\u6ea2\u4f4d\uff01\n\n\/\/ calloc \u6703\u5728\u5167\u90e8\u6aa2\u67e5\uff0c\u6ea2\u4f4d\u6642\u56de\u50b3 NULL\nuint8_t *buf = calloc(count, size);  \/\/ \u5b89\u5168<\/code><\/pre>\n<p>\u6211\u7684\u7fd2\u6163\uff1a<\/p>\n<ul>\n<li>\u9700\u8981\u6e05\u96f6\u7684\u7528 <code>calloc<\/code><\/li>\n<li>\u4e0d\u9700\u8981\u6e05\u96f6\uff08\u4e4b\u5f8c\u6703\u5b8c\u6574\u5beb\u5165\uff09\u7684\u7528 <code>malloc<\/code><\/li>\n<\/ul>\n<hr \/>\n<h2>realloc \u7684\u9677\u9631<\/h2>\n<p><code>realloc<\/code> \u662f\u6700\u5bb9\u6613\u8e29\u5751\u7684\uff1a<\/p>\n<pre><code class=\"language-c\">\/\/ \u274c \u7d93\u5178\u932f\u8aa4\u5beb\u6cd5\nbuf = realloc(buf, new_size);\nif (buf == NULL) {\n    \/\/ realloc \u5931\u6557\u4e86\n    \/\/ \u4f46\u539f\u672c\u7684 buf \u5df2\u7d93\u88ab free \u6389\u4e86\uff01\n    \/\/ \u9019\u88e1\u767c\u751f\u4e86\u8a18\u61b6\u9ad4\u6d29\u6f0f\n    return ERR_NO_MEMORY;\n}<\/code><\/pre>\n<p><code>realloc<\/code> \u5931\u6557\u7684\u6642\u5019\uff0c<strong>\u539f\u672c\u7684\u8a18\u61b6\u9ad4\u4e0d\u6703\u81ea\u52d5\u91cb\u653e<\/strong>\uff0c<br \/>\n\u4f46\u5982\u679c\u4f60\u76f4\u63a5\u628a\u56de\u50b3\u503c\u5b58\u56de <code>buf<\/code>\uff0c<br \/>\n\u539f\u672c\u7684\u6307\u6a19\u5c31\u4e1f\u5931\u4e86\uff0c\u8a18\u61b6\u9ad4\u5c31\u6d29\u6f0f\u4e86\u3002<\/p>\n<pre><code class=\"language-c\">\/\/ \u2705 \u6b63\u78ba\u5beb\u6cd5\nvoid *new_buf = realloc(buf, new_size);\nif (new_buf == NULL) {\n    \/\/ realloc \u5931\u6557\uff0cbuf \u9084\u662f\u6709\u6548\u7684\n    LOG_ERROR(&quot;realloc failed, new_size=%zu&quot;, new_size);\n    \/\/ \u4f60\u53ef\u4ee5\u9078\u64c7\u7e7c\u7e8c\u7528\u539f\u672c\u7684 buf\uff0c\u6216\u662f free \u6389\u5b83\n    free(buf);\n    buf = NULL;\n    return ERR_NO_MEMORY;\n}\nbuf = new_buf;  \/\/ \u6210\u529f\u624d\u66f4\u65b0 buf<\/code><\/pre>\n<p>\u7528\u4e00\u500b\u66ab\u6642\u7684\u6307\u6a19\u63a5 <code>realloc<\/code> \u7684\u56de\u50b3\u503c\uff0c<br \/>\n\u5931\u6557\u7684\u6642\u5019\u539f\u672c\u7684 <code>buf<\/code> \u9084\u5728\uff0c\u4f60\u53ef\u4ee5\u6c7a\u5b9a\u600e\u9ebc\u8655\u7406\u3002<\/p>\n<hr \/>\n<h2>\u5d4c\u5165\u5f0f\uff1a\u8a72\u4e0d\u8a72\u7528\u52d5\u614b\u8a18\u61b6\u9ad4\uff1f<\/h2>\n<p>\u9019\u500b\u554f\u984c\u5728\u5d4c\u5165\u5f0f\u793e\u7fa4\u88e1\u6709\u5f88\u591a\u8a0e\u8ad6\u3002<\/p>\n<p>\u6709\u4e9b\u56b4\u683c\u7684\u5d4c\u5165\u5f0f\u898f\u7bc4\uff08\u50cf\u662f MISRA-C\uff09<br \/>\n<strong>\u7981\u6b62\u5728\u57f7\u884c\u6642\u671f\u4f7f\u7528\u52d5\u614b\u8a18\u61b6\u9ad4\u914d\u7f6e<\/strong>\uff0c<br \/>\n\u539f\u56e0\u662f\uff1a<\/p>\n<ul>\n<li><strong>\u4e0d\u53ef\u9810\u6e2c\u6027<\/strong> \u2014 \u4e0d\u77e5\u9053\u4ec0\u9ebc\u6642\u5019\u6703\u5931\u6557<\/li>\n<li><strong>\u788e\u7247\u5316<\/strong> \u2014 \u9577\u6642\u9593\u57f7\u884c\u5f8c heap \u53ef\u80fd\u788e\u7247\u5316\uff0c\u5c0e\u81f4\u914d\u7f6e\u5931\u6557<\/li>\n<li><strong>\u5373\u6642\u6027<\/strong> \u2014 <code>malloc<\/code> \u7684\u57f7\u884c\u6642\u9593\u4e0d\u56fa\u5b9a\uff0c\u5c0d RTOS \u7684\u5373\u6642\u4efb\u52d9\u6709\u5f71\u97ff<\/li>\n<li><strong>\u96e3\u4ee5\u6e2c\u8a66<\/strong> \u2014 \u8a18\u61b6\u9ad4\u4e0d\u8db3\u7684\u60c5\u6cc1\u5f88\u96e3\u5728\u6e2c\u8a66\u4e2d\u91cd\u73fe<\/li>\n<\/ul>\n<pre><code>\u822a\u592a\u3001\u91ab\u7642\u3001\u6c7d\u8eca\u7b49\u5b89\u5168\u95dc\u9375\u7cfb\u7d71\uff0c\n\u901a\u5e38\u5b8c\u5168\u7981\u6b62\u52d5\u614b\u8a18\u61b6\u9ad4\u914d\u7f6e\u3002<\/code><\/pre>\n<hr \/>\n<h3>\u66ff\u4ee3\u65b9\u6848\uff1a\u975c\u614b\u8a18\u61b6\u9ad4\u6c60<\/h3>\n<p>\u5982\u679c\u9700\u8981\u300c\u52d5\u614b\u300d\u7684\u611f\u89ba\uff0c\u4f46\u53c8\u4e0d\u60f3\u7528 heap\uff0c<br \/>\n\u53ef\u4ee5\u81ea\u5df1\u505a\u4e00\u500b\u975c\u614b\u7684\u8a18\u61b6\u9ad4\u6c60\uff1a<\/p>\n<pre><code class=\"language-c\">#define POOL_BLOCK_SIZE   256\n#define POOL_BLOCK_COUNT  8\n\ntypedef struct {\n    uint8_t  data[POOL_BLOCK_SIZE];\n    bool     in_use;\n} MemBlock;\n\nstatic MemBlock s_pool[POOL_BLOCK_COUNT];\n\nvoid *pool_alloc(void) {\n    for (int i = 0; i &lt; POOL_BLOCK_COUNT; i++) {\n        if (!s_pool[i].in_use) {\n            s_pool[i].in_use = true;\n            memset(s_pool[i].data, 0, POOL_BLOCK_SIZE);\n            return s_pool[i].data;\n        }\n    }\n    LOG_ERROR(&quot;memory pool exhausted&quot;);\n    return NULL;\n}\n\nvoid pool_free(void *ptr) {\n    for (int i = 0; i &lt; POOL_BLOCK_COUNT; i++) {\n        if (s_pool[i].data == ptr) {\n            s_pool[i].in_use = false;\n            return;\n        }\n    }\n    LOG_ERROR(&quot;pool_free: invalid pointer&quot;);\n}<\/code><\/pre>\n<p>\u9019\u6a23\u505a\u7684\u597d\u8655\uff1a<\/p>\n<ul>\n<li>\u8a18\u61b6\u9ad4\u5728\u7de8\u8b6f\u6642\u671f\u5c31\u78ba\u5b9a\u4e86\uff0c\u4e0d\u6703\u6709\u788e\u7247\u5316<\/li>\n<li>\u914d\u7f6e\u548c\u91cb\u653e\u7684\u6642\u9593\u662f\u56fa\u5b9a\u7684<\/li>\n<li>\u53ef\u4ee5\u76e3\u63a7\u4f7f\u7528\u91cf\uff0c\u77e5\u9053\u6700\u591a\u540c\u6642\u7528\u4e86\u5e7e\u500b block<\/li>\n<\/ul>\n<p>\u7f3a\u9ede\u662f\u5f48\u6027\u6bd4\u8f03\u4f4e\uff0cblock \u5927\u5c0f\u56fa\u5b9a\uff0c<br \/>\n\u4e0d\u9069\u5408\u9700\u8981\u5404\u7a2e\u5927\u5c0f\u7684\u60c5\u6cc1\u3002<\/p>\n<hr \/>\n<h2>\u8aaa\u5be6\u8a71<\/h2>\n<p>\u5728\u5d4c\u5165\u5f0f\uff0c\u6211\u5c0d <code>malloc<\/code> \u7684\u614b\u5ea6\u662f\uff1a<br \/>\n<strong>\u80fd\u4e0d\u7528\u5c31\u4e0d\u7528\uff0c\u8981\u7528\u5c31\u8981\u7528\u5c0d\u3002<\/strong><\/p>\n<p>\u5f88\u591a\u60c5\u6cc1\u4e0b\uff0c\u975c\u614b\u914d\u7f6e\u5c31\u5920\u4e86\uff1a<\/p>\n<pre><code class=\"language-c\">\/\/ \u4e0d\u7528 malloc\uff0c\u76f4\u63a5\u975c\u614b\u914d\u7f6e\nstatic uint8_t rx_buf[RX_BUF_SIZE];\nstatic uint8_t tx_buf[TX_BUF_SIZE];<\/code><\/pre>\n<p>\u8a18\u61b6\u9ad4\u5728\u7de8\u8b6f\u6642\u671f\u5c31\u78ba\u5b9a\uff0c\u4e0d\u6703\u6709\u914d\u7f6e\u5931\u6557\u7684\u554f\u984c\uff0c<br \/>\n\u4e5f\u4e0d\u9700\u8981\u7ba1\u7406\u751f\u547d\u9031\u671f\u3002<\/p>\n<p>\u4f46\u5982\u679c\u771f\u7684\u9700\u8981\u52d5\u614b\u914d\u7f6e\uff0c<br \/>\n\u81f3\u5c11\u8981\u505a\u5230\uff1a<\/p>\n<ol>\n<li>\u6bcf\u6b21 <code>malloc<\/code> \u4e4b\u5f8c\u90fd\u6aa2\u67e5 <code>NULL<\/code><\/li>\n<li><code>free<\/code> \u4e4b\u5f8c\u7acb\u523b\u6e05\u7a7a\u6307\u6a19\uff08\u4e0a\u4e00\u7bc7\u8aaa\u904e\uff09<\/li>\n<li>\u6709\u8fa6\u6cd5\u76e3\u63a7 heap \u4f7f\u7528\u91cf<\/li>\n<\/ol>\n<p>\u7b2c\u4e09\u9ede\u5f88\u591a\u4eba\u5ffd\u7565\uff0c<br \/>\n\u4f46\u5728\u5d4c\u5165\u5f0f\uff0c\u77e5\u9053 heap \u7528\u4e86\u591a\u5c11\uff0c<br \/>\n\u53ef\u4ee5\u5e6b\u4f60\u5728\u554f\u984c\u767c\u751f\u4e4b\u524d\u5c31\u767c\u73fe\u7570\u5e38\u3002<\/p>\n<hr \/>\n<h2>\u9019\u7bc7\u7684 Checklist<\/h2>\n<ul>\n<li>[ ] \u6bcf\u6b21 <code>malloc<\/code> \/ <code>calloc<\/code> \u4e4b\u5f8c\u90fd\u6709\u6aa2\u67e5 <code>NULL<\/code><\/li>\n<li>[ ] <code>realloc<\/code> \u6709\u7528\u66ab\u6642\u6307\u6a19\u63a5\u56de\u50b3\u503c\uff0c\u4e0d\u662f\u76f4\u63a5\u8986\u84cb\u539f\u6307\u6a19<\/li>\n<li>[ ] <code>free<\/code> \u4e4b\u5f8c\u6709\u6e05\u7a7a\u6307\u6a19\uff08<code>= NULL<\/code>\uff09<\/li>\n<li>[ ] \u9700\u8981\u6e05\u96f6\u7684\u5730\u65b9\u7528 <code>calloc<\/code> \u53d6\u4ee3 <code>malloc<\/code> + <code>memset<\/code><\/li>\n<li>[ ] \u8a55\u4f30\u904e\u662f\u5426\u771f\u7684\u9700\u8981\u52d5\u614b\u8a18\u61b6\u9ad4\uff0c\u975c\u614b\u914d\u7f6e\u662f\u5426\u53ef\u884c<\/li>\n<li>[ ] \u6709\u8fa6\u6cd5\u76e3\u63a7 heap \u4f7f\u7528\u91cf\uff08\u5d4c\u5165\u5f0f\uff09<\/li>\n<li>[ ] \u9577\u6642\u9593\u57f7\u884c\u7684\u7cfb\u7d71\u6709\u8003\u616e heap \u788e\u7247\u5316\u554f\u984c<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5e73\u5e38\u5728\u5d4c\u5165\u5f0f\u7cfb\u7d71\u4e0a\u7528 malloc\uff0c \u5beb\u5b8c\u4e4b\u5f8c\u89ba\u5f97\u5f88\u723d\uff0c\u52d5\u614b\u914d\u7f6e\u8a18\u61b6\u9ad4\uff0c\u597d\u50cf\u5f88\u53b2 &hellip; <a href=\"https:\/\/hsiang.cc\/?p=868\">\u95b1\u8b80\u5168\u6587 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[995,912,922,1002,989,974,998,994,1001,996,1000,919,997,999,917],"class_list":{"0":"post-868","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"tag-calloc-vs-malloc","8":"tag-c","13":"tag-heap","14":"tag-mallocnull","15":"tag-misra-c","16":"tag-realloc","17":"tag-1000","19":"tag-997","20":"tag-999","21":"tag-917"},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/hsiang.cc\/index.php?rest_route=\/wp\/v2\/posts\/868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hsiang.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hsiang.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hsiang.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hsiang.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=868"}],"version-history":[{"count":3,"href":"https:\/\/hsiang.cc\/index.php?rest_route=\/wp\/v2\/posts\/868\/revisions"}],"predecessor-version":[{"id":871,"href":"https:\/\/hsiang.cc\/index.php?rest_route=\/wp\/v2\/posts\/868\/revisions\/871"}],"wp:attachment":[{"href":"https:\/\/hsiang.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hsiang.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hsiang.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}