Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Creating-and-Freeing-a-Hash-Table.html 5.2KB

vor 3 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the BFD library.
  4. Copyright (C) 1991-2020 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3 or
  7. any later version published by the Free Software Foundation; with the
  8. Invariant Sections being "GNU General Public License" and "Funding
  9. Free Software", the Front-Cover texts being (a) (see below), and with
  10. the Back-Cover Texts being (b) (see below). A copy of the license is
  11. included in the section entitled "GNU Free Documentation License".
  12. (a) The FSF's Front-Cover Text is:
  13. A GNU Manual
  14. (b) The FSF's Back-Cover Text is:
  15. You have freedom to copy and modify this GNU Manual, like GNU
  16. software. Copies published by the Free Software Foundation raise
  17. funds for GNU development. -->
  18. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <title>Creating and Freeing a Hash Table (Untitled Document)</title>
  22. <meta name="description" content="Creating and Freeing a Hash Table (Untitled Document)">
  23. <meta name="keywords" content="Creating and Freeing a Hash Table (Untitled Document)">
  24. <meta name="resource-type" content="document">
  25. <meta name="distribution" content="global">
  26. <meta name="Generator" content="makeinfo">
  27. <link href="index.html#Top" rel="start" title="Top">
  28. <link href="BFD-Index.html#BFD-Index" rel="index" title="BFD Index">
  29. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  30. <link href="Hash-Tables.html#Hash-Tables" rel="up" title="Hash Tables">
  31. <link href="Looking-Up-or-Entering-a-String.html#Looking-Up-or-Entering-a-String" rel="next" title="Looking Up or Entering a String">
  32. <link href="Hash-Tables.html#Hash-Tables" rel="prev" title="Hash Tables">
  33. <style type="text/css">
  34. <!--
  35. a.summary-letter {text-decoration: none}
  36. blockquote.indentedblock {margin-right: 0em}
  37. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  38. blockquote.smallquotation {font-size: smaller}
  39. div.display {margin-left: 3.2em}
  40. div.example {margin-left: 3.2em}
  41. div.lisp {margin-left: 3.2em}
  42. div.smalldisplay {margin-left: 3.2em}
  43. div.smallexample {margin-left: 3.2em}
  44. div.smalllisp {margin-left: 3.2em}
  45. kbd {font-style: oblique}
  46. pre.display {font-family: inherit}
  47. pre.format {font-family: inherit}
  48. pre.menu-comment {font-family: serif}
  49. pre.menu-preformatted {font-family: serif}
  50. pre.smalldisplay {font-family: inherit; font-size: smaller}
  51. pre.smallexample {font-size: smaller}
  52. pre.smallformat {font-family: inherit; font-size: smaller}
  53. pre.smalllisp {font-size: smaller}
  54. span.nolinebreak {white-space: nowrap}
  55. span.roman {font-family: initial; font-weight: normal}
  56. span.sansserif {font-family: sans-serif; font-weight: normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en">
  62. <a name="Creating-and-Freeing-a-Hash-Table"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Looking-Up-or-Entering-a-String.html#Looking-Up-or-Entering-a-String" accesskey="n" rel="next">Looking Up or Entering a String</a>, Previous: <a href="Hash-Tables.html#Hash-Tables" accesskey="p" rel="prev">Hash Tables</a>, Up: <a href="Hash-Tables.html#Hash-Tables" accesskey="u" rel="up">Hash Tables</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Creating-and-freeing-a-hash-table"></a>
  69. <h4 class="subsection">2.18.1 Creating and freeing a hash table</h4>
  70. <a name="index-bfd_005fhash_005ftable_005finit"></a>
  71. <a name="index-bfd_005fhash_005ftable_005finit_005fn"></a>
  72. <p>To create a hash table, create an instance of a <code>struct
  73. bfd_hash_table</code> (defined in <code>bfd.h</code>) and call
  74. <code>bfd_hash_table_init</code> (if you know approximately how many
  75. entries you will need, the function <code>bfd_hash_table_init_n</code>,
  76. which takes a <var>size</var> argument, may be used).
  77. <code>bfd_hash_table_init</code> returns <code>FALSE</code> if some sort of
  78. error occurs.
  79. </p>
  80. <a name="index-bfd_005fhash_005fnewfunc"></a>
  81. <p>The function <code>bfd_hash_table_init</code> take as an argument a
  82. function to use to create new entries. For a basic hash
  83. table, use the function <code>bfd_hash_newfunc</code>. See <a href="Deriving-a-New-Hash-Table-Type.html#Deriving-a-New-Hash-Table-Type">Deriving a New Hash Table Type</a>, for why you would want to use a
  84. different value for this argument.
  85. </p>
  86. <a name="index-bfd_005fhash_005fallocate"></a>
  87. <p><code>bfd_hash_table_init</code> will create an objalloc which will be
  88. used to allocate new entries. You may allocate memory on this
  89. objalloc using <code>bfd_hash_allocate</code>.
  90. </p>
  91. <a name="index-bfd_005fhash_005ftable_005ffree"></a>
  92. <p>Use <code>bfd_hash_table_free</code> to free up all the memory that has
  93. been allocated for a hash table. This will not free up the
  94. <code>struct bfd_hash_table</code> itself, which you must provide.
  95. </p>
  96. <a name="index-bfd_005fhash_005fset_005fdefault_005fsize"></a>
  97. <p>Use <code>bfd_hash_set_default_size</code> to set the default size of
  98. hash table to use.
  99. </p>
  100. </body>
  101. </html>