{"id":50,"date":"2014-07-03T08:55:13","date_gmt":"2014-07-03T08:55:13","guid":{"rendered":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?p=50"},"modified":"2014-07-04T16:28:22","modified_gmt":"2014-07-04T16:28:22","slug":"the-ovm_str_t-type","status":"publish","type":"post","link":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?p=50","title":{"rendered":"The ovm_str_t type"},"content":{"rendered":"<p>The <code>ovm_str_t<\/code> type is the OrchIDS type of (fixed-size) character strings.<\/p>\n<p><!--more--><\/p>\n<p>It is defined this way in <tt>src\/lang.h<\/tt>:<\/p>\n<pre>typedef struct ovm_str_s ovm_str_t;\r\nstruct ovm_str_s\r\n{\r\n  gc_header_t gc;\r\n  size_t    len;\r\n  char      str[STR_PAD_LEN];\r\n};<\/pre>\n<p>The <code>str<\/code> field is defined with a dummy length of <code>STR_PAD_LEN<\/code>; its actual length is given by the <code>len<\/code> field.<\/p>\n<p>The type <code>ovm_str_t<\/code> is a type of <a title=\"Garbage collection\" href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?p=18\">garbage-collectable<\/a> data. To allocate a new object of type <code>ovm_str_t<\/code>, use the function:<\/p>\n<pre>ovm_var_t *ovm_str_new(gc_t *gc_ctx, size_t size);<\/pre>\n<p>This creates a new <code>ovm_str_t<\/code> containing <code>size<\/code> bytes. Calling <code>res<\/code> the result, one always has <code>TYPE(res)==T_STR<\/code>. The actual array of bytes is left uninitialized. One can access it using <code>STR(res)<\/code>, and its length (<code>size<\/code>) is <code>STRLEN(res)<\/code>.<\/p>\n<p>The return type of <code>ovm_str_new()<\/code> is the universal type <a title=\"The ovm_var_t universal type\" href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?page_id=121\"><code>ovm_var_t<\/code><\/a> instead of <code>ovm_str_t<\/code>, for practical reasons.<\/p>\n<p>The result is created white, and much be <code>gc_touch()<\/code>ed before storing it into a garbage-collectable object.<\/p>\n<p>The returned <code>ovm_str_t<\/code> object <code>res<\/code> is modifiable.<\/p>\n<p>There is also a type of <strong>virtual<\/strong> character strings <a title=\"The ovm_vstr_t type\" href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?p=53\"><code>ovm_vstr_t<\/code><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ovm_str_t type is the OrchIDS type of (fixed-size) character strings.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-50","post","type-post","status-publish","format-standard","hentry","category-data-types","category-virtual-machine"],"_links":{"self":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=50"}],"version-history":[{"count":5,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/posts\/50\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}