search_algorithms.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. void * best_fit_on_freelist(heap_t *heap, size_t requested_size);
  41. /**
  42. * Perform a good-fit search on the free list
  43. *
  44. * \param heap The heap whose free list should be accessed.
  45. * \param requested_size The desired size of the block.
  46. * \param fit_percentage The lowest acceptable percentage of the block space to be filled.
  47. *
  48. * \return The pointer to the data part of the matched memory block.
  49. * \retval NULL No block was found.
  50. */
  51. void * good_fit_on_freelist(heap_t *heap, size_t requested_size, float fit_percentage);
  52. void * exact_fit_on_freelist(heap_t *heap, size_t requested_size);
  53. void * first_fit_on_freelist(heap_t *heap, size_t requested_size);
  54. #endif /* LINKED_LISTS_SEARCH_ALGORITHMS_H */