{"id":38,"date":"2014-07-03T08:28:08","date_gmt":"2014-07-03T08:28:08","guid":{"rendered":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?p=38"},"modified":"2014-07-04T16:29:13","modified_gmt":"2014-07-04T16:29:13","slug":"the-ovm_bstr_new-type","status":"publish","type":"post","link":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?p=38","title":{"rendered":"The ovm_bstr_t type"},"content":{"rendered":"<p>The <code>ovm_bstr_t<\/code> type is the OrchIDS type of binary strings: fixed-size arrays of bytes.<\/p>\n<p><!--more--><\/p>\n<p>It is defined this way in <tt>src\/lang.h<\/tt>:<\/p>\n<pre>typedef struct ovm_bstr_s ovm_bstr_t;\r\nstruct ovm_bstr_s\r\n{\r\n  gc_header_t gc;\r\n  size_t    len;\r\n  uint8_t   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_bstr_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_bstr_t<\/code>, use the function:<\/p>\n<pre>ovm_var_t *ovm_bstr_new (gc_t *gc_ctx, size_t size);<\/pre>\n<p>This creates a new <code>ovm_bstr_t<\/code> object containing <code>size<\/code> bytes. Calling <code>res<\/code> the result, one always has <code>TYPE(res)==T_BSTR<\/code>. The actual array of bytes is left uninitialized. One can access it using <code>BSTR(res)<\/code>, and its length (<code>size<\/code>) is <code>BSTRLEN(res)<\/code>.<\/p>\n<p>The return type of <code>ovm_bstr_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_bstr_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_bstr_t<\/code> object res is modifiable.<\/p>\n<p>There is also a type of <strong>virtual<\/strong> binary strings <a title=\"The ovm_vbstr_t type\" href=\"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/?p=43\"><code>ovm_vbstr_t<\/code>.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ovm_bstr_t type is the OrchIDS type of binary strings: fixed-size arrays of bytes.<\/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-38","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\/38","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=38"}],"version-history":[{"count":8,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":134,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions\/134"}],"wp:attachment":[{"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projects.lsv.ens-paris-saclay.fr\/orchidsdev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}