{"id":177,"date":"2016-01-14T13:28:47","date_gmt":"2016-01-14T13:28:47","guid":{"rendered":"http:\/\/emacslisp.com\/?p=177"},"modified":"2016-01-14T13:31:48","modified_gmt":"2016-01-14T13:31:48","slug":"tcc-source-code-define_stack-and-tcc_alloc","status":"publish","type":"post","link":"http:\/\/emacslisp.com\/?p=177","title":{"rendered":"TCC source code &#8212; define_stack and tcc_alloc"},"content":{"rendered":"<p>define_stack is good example of lots of stack using TCC. The following is example of print Define Stack.<\/p>\n<pre lang=\"c\" line=\"1\"> \r\nvoid printDefineStack(){\r\n  Sym *p = define_stack;\r\n  for(;;){\r\n    if(p == NULL){\r\n      break;\r\n    }\r\n    \r\n    printf(\"%d\\n\",p -> v);\r\n    p = p -> prev; \r\n  }\r\n}\r\n<\/pre>\n<p>tcc_alloc is function which is allocated tcc object, It is very simple and used everywhere in tcc. Here is example on how to use it.<\/p>\n<pre lang=\"c\" line=\"1\"> \r\nvoid tcc_alloc_test()\r\n{\r\n  int i = 0;\r\n  int len =  3;\r\n  char *str = \"int\";\r\n  TokenSym *ts;  \r\n  table_ident = tcc_malloc((TOK_ALLOC_INCR) * sizeof(TokenSym *));\r\n  \r\n  ts = tcc_malloc(sizeof(TokenSym) + len);\r\n  table_ident[i] = ts;\r\n\r\n  ts->sym_define = NULL;\r\n  ts->sym_label = NULL;\r\n  ts->sym_struct = NULL;\r\n  ts->sym_identifier = NULL;\r\n  ts->len = len;\r\n  ts->hash_next = NULL;\r\n  memcpy(ts->str, str, len);\r\n  ts->str[len] = '\\0';\r\n\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>define_stack is good example of lots of stack using TCC. The following is example of print Define Stack. void printDefineStack(){ Sym *p = define_stack; for(;;){ if(p == NULL){ break; } printf(&#8220;%d\\n&#8221;,p -> v); p = p -> prev; } } tcc_alloc is function which is allocated tcc object, It is very simple and used everywhere [&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-177","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\/177","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=177"}],"version-history":[{"count":1,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":178,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions\/178"}],"wp:attachment":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}