Lists-of-Pairs-of-Ports.html 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <html lang="en">
  2. <head>
  3. <title>Lists of Pairs of Ports - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Emulation-Primitives.html#Emulation-Primitives" title="Emulation Primitives">
  9. <link rel="prev" href="Emulation-Primitives.html#Emulation-Primitives" title="Emulation Primitives">
  10. <link rel="next" href="Ports-and-Packets.html#Ports-and-Packets" title="Ports and Packets">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Lists-of-Pairs-of-Ports"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Ports-and-Packets.html#Ports-and-Packets">Ports and Packets</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Emulation-Primitives.html#Emulation-Primitives">Emulation Primitives</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Emulation-Primitives.html#Emulation-Primitives">Emulation Primitives</a>
  32. <hr>
  33. </div>
  34. <h4 class="subsection">3.8.1 Lists of Pairs of Ports</h4>
  35. <p><a name="index-g_t_0040code_007bport_007d-628"></a>A <code>port</code> is the name given to a type of pointer used in the library
  36. as the address of a place where a computational result yet to be
  37. evaluated will be sent. Ports are discussed further in <a href="Ports-and-Packets.html#Ports-and-Packets">Ports and Packets</a>,
  38. but are mentioned here because it is sometimes necessary to employ a
  39. list of pairs of them. A pointer to such a list is declared as a
  40. <code>portal</code> type. It refers to a structure of the form
  41. <a name="index-g_t_0040code_007bportal_007d-629"></a><a name="index-g_t_0040code_007bport_005fpair_007d-630"></a>
  42. <pre class="example"> struct port_pair
  43. {
  44. port left;
  45. port right;
  46. portal alters;
  47. }
  48. </pre>
  49. <p>A small selection of functions for <code>portal</code> memory management is
  50. declared as follows in the header file <samp><span class="file">portals.h</span></samp>. For reasons of
  51. C-ness, the type declarations themselves are forced to be in
  52. <samp><span class="file">lists.h</span></samp>.
  53. <div class="defun">
  54. &mdash; Function: portal <b>avm_new_portal</b> (<var>portal alters</var>)<var><a name="index-avm_005fnew_005fportal-631"></a></var><br>
  55. <blockquote><p>This function is used to create storage for a new <code>port_pair</code>
  56. structure, and returns a <code>portal</code> pointer to it if successful. If
  57. the storage can't be allocated, a <code>NULL</code> pointer is returned.
  58. The <code>alters</code> field of the result is initialized as the given
  59. parameter supplied by the caller. All other fields are filled with zeros.
  60. </p></blockquote></div>
  61. <div class="defun">
  62. &mdash; Function: void <b>avm_seal</b> (<var>portal fate</var>)<var><a name="index-avm_005fseal-632"></a></var><br>
  63. <blockquote><p>This function performs the reclamation of storage associated with
  64. <code>portal</code> pointers, either by freeing them or by consigning them
  65. temporarily to a local cache for performance reasons. Client programs
  66. should use only this function for disposing of <code>portal</code> storage
  67. rather than using <code>free</code> directly, so as to allow accurate record
  68. keeping.
  69. </p></blockquote></div>
  70. <div class="defun">
  71. &mdash; Function: void <b>avm_initialize_portals</b> ()<var><a name="index-avm_005finitialize_005fportals-633"></a></var><br>
  72. <blockquote><p>This function should be called by a client program prior to calling
  73. either of the above memory management functions in order to initialize
  74. some local variables. Anomalous results are possible otherwise.
  75. </p></blockquote></div>
  76. <div class="defun">
  77. &mdash; Function: void <b>avm_count_portals</b> ()<var><a name="index-avm_005fcount_005fportals-634"></a></var><br>
  78. <blockquote><p>This function should be called at the end of a run or after the last
  79. call to any of the other functions in this section as a way of detecting
  80. memory leaks associated with <code>portal</code> pointers. A warning message
  81. will be written to standard error if any remains unreclaimed.
  82. </p></blockquote></div>
  83. </body></html>