{"id":294,"date":"2016-10-24T12:12:49","date_gmt":"2016-10-24T12:12:49","guid":{"rendered":"http:\/\/emacslisp.com\/?p=294"},"modified":"2016-11-29T06:25:16","modified_gmt":"2016-11-29T06:25:16","slug":"tcc-dynarray_add","status":"publish","type":"post","link":"http:\/\/emacslisp.com\/?p=294","title":{"rendered":"TCC &#8211; dynarray_add"},"content":{"rendered":"<p>This is very common function in TCC state.<\/p>\n<p>here is main logical.<\/p>\n<pre lang=\"c\" line=\"1\"> \r\ndynarray_add(void ***ptab, int *nb_ptr, void *data) \r\n{\r\n...\r\npp= *ptab; nb=*nb_ptr;\r\npp[nb++] = data;\r\n...\r\n}\r\n<\/pre>\n<p>what dynarray_add do is simple. input array has just 3 parts that is double pointer, index and value.<\/p>\n<p>then assign data to double pointer just like assign string to char array.<\/p>\n<p>Here is sample call stack, it call to add pathname into library_paths.<\/p>\n<pre lang=\"c\" line=\"1\">\r\ndynarray_add(p_ary, p_nb_ary, str.data);\r\ntcc_split_path(TCCState *s, void ***p_ary, int *p_nb_ary, const char *in)\r\ntcc_split_path(s, (void ***)&s->library_paths, &s->nb_library_paths, pathname);\r\n<\/pre>\n<p>the define of library_paths is following<\/p>\n<pre lang=\"c\" line=\"1\">\r\nstruct TCCState {\r\n...\r\n    char **library_paths;\r\n    int nb_library_paths;\r\n...\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is very common function in TCC state. here is main logical. dynarray_add(void ***ptab, int *nb_ptr, void *data) { &#8230; pp= *ptab; nb=*nb_ptr; pp[nb++] = data; &#8230; } what dynarray_add do is simple. input array has just 3 parts that is double pointer, index and value. then assign data to double pointer just like assign [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-294","post","type-post","status-publish","format-standard","hentry","category-tcc-source-code-analysis"],"_links":{"self":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":3,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":298,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions\/298"}],"wp:attachment":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}