123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <html lang="en">
- <head>
- <title>One dimensional arrays - avram - a virtual machine code interpreter</title>
- <meta http-equiv="Content-Type" content="text/html">
- <meta name="description" content="avram - a virtual machine code interpreter">
- <meta name="generator" content="makeinfo 4.13">
- <link title="Top" rel="start" href="index.html#Top">
- <link rel="up" href="Type-Conversions.html#Type-Conversions" title="Type Conversions">
- <link rel="prev" href="Primitive-types.html#Primitive-types" title="Primitive types">
- <link rel="next" href="Two-dimensional-arrays.html#Two-dimensional-arrays" title="Two dimensional arrays">
- <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
- <meta http-equiv="Content-Style-Type" content="text/css">
- <style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
- span.sansserif { font-family:sans-serif; font-weight:normal; }
- --></style>
- </head>
- <body>
- <div class="node">
- <a name="One-dimensional-arrays"></a>
- <p>
- Next: <a rel="next" accesskey="n" href="Two-dimensional-arrays.html#Two-dimensional-arrays">Two dimensional arrays</a>,
- Previous: <a rel="previous" accesskey="p" href="Primitive-types.html#Primitive-types">Primitive types</a>,
- Up: <a rel="up" accesskey="u" href="Type-Conversions.html#Type-Conversions">Type Conversions</a>
- <hr>
- </div>
- <h5 class="subsubsection">3.1.4.2 One dimensional arrays</h5>
- <p>A couple of functions declared in <samp><span class="file">matcon.h</span></samp> are concerned mainly
- with one dimensional arrays or vectors. They have been used for
- <a name="index-arrays-445"></a>vectors of double precision and complex numbers, but are applicable to
- <a name="index-vectors-446"></a>any base type that is contiguous and of a fixed size.
- <p>The motivation for these functions is to enable a developer to present
- an API to virtual code applications wherein external library functions
- operating natively on one dimensional arrays of numbers are seen from
- the virtual side to operate on lists of numbers. Lists are the
- preferred container for interoperability with virtual code
- applications.
- <div class="defun">
- — Function: void <b>*avm_vector_of_list</b> (<var>list operand, size_t item_size, list *message, int *fault</var>)<var><a name="index-g_t_002aavm_005fvector_005fof_005flist-447"></a></var><br>
- <blockquote><p>This function calls <code>avm_value_of_list</code> (<a href="Primitive-types.html#Primitive-types">Primitive types</a>)
- for each item of the <var>operand</var> and puts all the values together
- into one contiguous block, whose address is returned.
- <p>The given <var>item_size</var> is required to be the lengths of the items,
- all necessarily equal, and is required only for validation. For
- example, <var>item_size</var> is 8 for a list of double precision numbers,
- because they occupy 8 bytes each and are represented as lists of length 8.
- <p>The total number of bytes allocated is the product of <var>item_size</var>
- and the length of the <var>operand</var>. Unlike the case of
- <code>avm_value_of_list</code> (<a href="Primitive-types.html#Primitive-types">Primitive types</a>), the result returned
- by this function should be explicitly freed by the caller when no
- longer needed.
- <p>Any errors such as insufficient memory cause the integer referenced by
- <var>fault</var> to be assigned a non-zero value and the <var>message</var> to
- be assigned an error message represented as a list of strings. An
- error message of <code><'bad vector specification'></code> is possible in
- the case of an empty <var>operand</var> or one whose item lengths don't
- match the given <var>item_size</var>. Error messages caused by
- <code>avm_value_of_list</code> can also be generated by this function. Any
- non-empty error message should be reclaimed by the caller using
- <code>avm_dispose</code> (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a>). If an error occurs, a
- <code>NULL</code> pointer is returned.
- </p></blockquote></div>
- <div class="defun">
- — Function: list <b>avm_list_of_vector</b> (<var>void *vector, int num_items, size_t item_size, int *fault</var>)<var><a name="index-avm_005flist_005fof_005fvector-448"></a></var><br>
- <blockquote><p>This function takes it on faith that an array of dimension
- <var>num_items</var> in which each item occupies <var>item_size</var> bytes
- begins at the address given by <var>vector</var>. A list representation of
- each item in the array is constructed by the function
- <code>avm_list_of_value</code> (<a href="Primitive-types.html#Primitive-types">Primitive types</a>), and a list of all of
- the lists thus obtained in order of their position in the array is
- returned.
- <p>In the event of any errors caused by <code>avm_list_of_value</code> or
- errors due to insufficient memory, the error message is returned as
- the function result, and the integer referenced by <var>fault</var> is
- assigned a non-zero value. The error message is in the form of a list
- of character string representations. A segmentation fault is possible
- <a name="index-segmentation-fault-449"></a>if <var>vector</var> is not a valid pointer or if the array size implied by
- misspecified values of <var>num_items</var> and <var>item_size</var>
- exceeds its actual size.
- </p></blockquote></div>
- </body></html>
|