search_algorithms.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 "dmm_config.h"
  27. #include "freelist/freelist_rb.h"
  28. /**
  29. * Perform a best-fit search on free lists for a block of a certain size
  30. *
  31. * \param raw_block The raw block whose fixed list should be accessed.
  32. * \param requested_size The desired size of the block.
  33. *
  34. * \return The pointer of the data part of the matched memory block.
  35. * \retval NULL No block was found.
  36. */
  37. block_header_t * best_fit_on_freelist(freelist_rb_t *raw_block, size_t requested_size);
  38. #ifdef GOOD_FIT
  39. /**
  40. * Perform a good-fit search on the free list
  41. *
  42. * \param raw_block The raw block whose fixed list should be accessed.
  43. * \param requested_size The desired size of the block.
  44. *
  45. * \return The pointer to the data part of the matched memory block.
  46. * \retval NULL No block was found.
  47. */
  48. block_header_t * good_fit_on_freelist(freelist_rb_t *raw_block, size_t requested_size);
  49. #endif /* GOOD_FIT */
  50. /**
  51. * Perform an exact-fit search on free lists for a block of a certain size
  52. *
  53. * \param raw_block The raw block whose fixed list should be accessed.
  54. * \param requested_size The desired size of the block.
  55. *
  56. * \return The pointer of the data part of the matched memory block.
  57. * \retval NULL No block was found.
  58. */
  59. block_header_t * exact_fit_on_freelist(freelist_rb_t *raw_block, size_t requested_size);
  60. /**
  61. * Perform a first-fit search on free lists for a block of a certain size
  62. *
  63. * \param raw_block The raw block whose fixed list should be accessed.
  64. * \param requested_size The desired size of the block.
  65. *
  66. * \return The pointer of the data part of the matched memory block.
  67. * \retval NULL No block was found.
  68. */
  69. block_header_t * first_fit_on_freelist(freelist_rb_t *raw_block, size_t requested_size);
  70. #endif /* LINKED_LISTS_SEARCH_ALGORITHMS_H */