search_algorithms.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright 2011 Institute of Communication and Computer Systems (ICCS)
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. /**
  18. * \file search_algorithms.h
  19. * \author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * \date September, 2011
  21. *
  22. * \brief Various search algorithms for linked list structures used on DMMLib.
  23. */
  24. #ifndef LINKED_LISTS_SEARCH_ALGORITHMS_H
  25. #define LINKED_LISTS_SEARCH_ALGORITHMS_H
  26. #include <dmmlib/heap.h>
  27. #include <dmm_config.h>
  28. #ifdef WITH_FIXED_LISTS
  29. /**
  30. * Perform an exact-fit search on fixed lists for a block of a certain size
  31. *
  32. * \param heap The heap whose fixed lists should be accessed.
  33. * \param requested_size The desired size of the block.
  34. *
  35. * \return The pointer of the data part of the matched memory block.
  36. * \retval NULL No block was found.
  37. */
  38. void * search_on_fixed(heap_t * heap, size_t requested_size);
  39. #endif /* WITH_FIXED_LISTS */
  40. /**
  41. * Perform a best-fit search on free lists for a block of a certain size
  42. *
  43. * \param heap The heap whose fixed lists should be accessed.
  44. * \param requested_size The desired size of the block.
  45. *
  46. * \return The pointer of the data part of the matched memory block.
  47. * \retval NULL No block was found.
  48. */
  49. void * best_fit_on_freelist(heap_t *heap, size_t requested_size);
  50. #ifdef GOOD_FIT
  51. /**
  52. * Perform a good-fit search on the free list
  53. *
  54. * \param heap The heap whose free list should be accessed.
  55. * \param requested_size The desired size of the block.
  56. *
  57. * \return The pointer to the data part of the matched memory block.
  58. * \retval NULL No block was found.
  59. */
  60. void * good_fit_on_freelist(heap_t *heap, size_t requested_size);
  61. #endif /* GOOD_FIT */
  62. /**
  63. * Perform an exact-fit search on free lists for a block of a certain size
  64. *
  65. * \param heap The heap whose fixed lists should be accessed.
  66. * \param requested_size The desired size of the block.
  67. *
  68. * \return The pointer of the data part of the matched memory block.
  69. * \retval NULL No block was found.
  70. */
  71. void * exact_fit_on_freelist(heap_t *heap, size_t requested_size);
  72. /**
  73. * Perform a first-fit search on free lists for a block of a certain size
  74. *
  75. * \param heap The heap whose fixed lists should be accessed.
  76. * \param requested_size The desired size of the block.
  77. *
  78. * \return The pointer of the data part of the matched memory block.
  79. * \retval NULL No block was found.
  80. */
  81. void * first_fit_on_freelist(heap_t *heap, size_t requested_size);
  82. #endif /* LINKED_LISTS_SEARCH_ALGORITHMS_H */