address_order.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <stdbool.h>
  18. #include "block_header.h"
  19. #include "linked_lists/add_block_in_order.h"
  20. #include "linked_lists/address_order.h"
  21. bool has_smaller_address(void* block, void* comparing_block);
  22. bool has_smaller_address(void* block, void* comparing_block) {
  23. if(block < comparing_block) {
  24. return true;
  25. } else {
  26. return false;
  27. }
  28. }
  29. #ifdef COUNT_HOPS
  30. void add_block_address_order(
  31. heap_t *heap,
  32. void **block,
  33. void **starting_node) {
  34. add_block_in_order(
  35. heap,
  36. block,
  37. starting_node,
  38. has_smaller_address);
  39. }
  40. #else /* COUNT_HOPS */
  41. void add_block_address_order(
  42. void **block,
  43. void **starting_node) {
  44. add_block_in_order(
  45. block,
  46. starting_node,
  47. has_smaller_address);
  48. }
  49. #endif /* COUNT_HOPS */