{"id":828,"date":"2018-10-10T10:31:03","date_gmt":"2018-10-10T10:31:03","guid":{"rendered":"https:\/\/ibex.tech\/c\/?p=828"},"modified":"2022-12-01T10:33:18","modified_gmt":"2022-12-01T10:33:18","slug":"malloc","status":"publish","type":"post","link":"https:\/\/ibex.tech\/c\/c\/memory\/malloc","title":{"rendered":"Malloc"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Temporary memory example<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/CREATE TEMPORARY MEMORY BUFFER\n\tuint32_t *my_temporary_memory_buffer = malloc(1024 * sizeof(uint32_t));\t\/\/Allocate a block of size bytes of memory, returning a pointer to the beginning of the block.  Use calloc() to do same but zero initialise the buffer.\n\tif (my_temporary_memory_buffer != NULL)\n\t{\n\t\t\n\t\t\/\/Use my_temporary_memory_buffer as needed \n\t\tmy_temporary_memory_buffer&#91;0] = 1234;\n\t\t\n\t\t\/\/RELEASE TEMPORARY MEMORY BUFFER\n\t\tfree(my_temporary_memory_buffer);\t\t\t\t\t\t\t\t\t\/\/Deallocate the block of memory, making it available again for future allocations\n\t}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Functions<\/h4>\n\n\n\n<p>malloc(size_t size) allocates the requested memory (size specified in bytes) and returns a pointer to it.<\/p>\n\n\n\n<p>realloc()<\/p>\n\n\n\n<p>free()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Temporary memory example Functions malloc(size_t size) allocates the requested memory (size specified in bytes) and returns a pointer to it. realloc() free()<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-828","post","type-post","status-publish","format-standard","hentry","category-memory"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/comments?post=828"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/828\/revisions"}],"predecessor-version":[{"id":1305,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/828\/revisions\/1305"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/media?parent=828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/categories?post=828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/tags?post=828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}