block_header.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 block_header.h
  19. * \author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * \date September, 2011
  21. *
  22. * \brief Block header structure and functions, and memory block functions.
  23. */
  24. #ifndef BLOCK_HEADER_H
  25. #define BLOCK_HEADER_H
  26. #include <stddef.h>
  27. #include <stdbool.h>
  28. #include "dmm_config.h"
  29. /** The header structure of every memory block inside a heap. */
  30. typedef struct block_header_s {
  31. size_t size; /**< The LSB represents the availability of the block (1 for
  32. used, 0 for free), the rest the size of the data part. */
  33. #ifdef REQUEST_SIZE_INFO
  34. size_t requested_size; /**< The requested size of the data part */
  35. #endif /* REQUEST_SIZE_INFO */
  36. size_t previous_size; /**< The LSB represents the availability of the
  37. previous block, the rest the size of the data
  38. part of the previous block in the memory space */
  39. struct block_header_s *next; /**< The pointer to the next memory block in the list */
  40. #ifdef BLOCKS_IN_DLL
  41. struct block_header_s *previous; /**< The pointer to the previous node in the list */
  42. #endif /* BLOCKS_IN_DLL */
  43. } block_header_t;
  44. /**
  45. * The size of the header in number of bytes
  46. */
  47. #define HEADER_SIZE sizeof(block_header_t)
  48. #endif /* BLOCK_HEADER_H */