test.c 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <stdio.h>
  2. #include "heap.h"
  3. #include "other.h"
  4. #include "posix_lock.h"
  5. #include "dmm_init.h"
  6. void *first_fit_search(unsigned int size, NODE *starting_node,
  7. char is_fixed_global) {
  8. NODE *node;
  9. node = starting_node;
  10. while(node) {
  11. }
  12. }
  13. void *custom_malloc(heap_t* heap, unsigned int size);
  14. void *custom_malloc(heap_t* heap, unsigned int size) {
  15. void *ptr;
  16. int fixed_list_id;
  17. ptr = NULL;
  18. posix_lock(heap);
  19. fixed_list_id = map_size_to_list(heap, size);
  20. if(fixed_list_id != -1) {
  21. // first fit from fixed list
  22. }
  23. if(ptr == NULL) {
  24. // first fit from free list
  25. }
  26. posix_unlock(heap);
  27. return ptr;
  28. }
  29. int main(void) {
  30. allocator_t *myallocator;
  31. heap_t *myheap;
  32. int heap_id;
  33. myallocator = dmm_init();
  34. heap_id = map_thread_heap();
  35. printf("This thread accesses heap %d\n", heap_id);
  36. myheap = &myallocator->heaps[heap_id];
  37. }