bitmap.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 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 bitmap.h
  19. * @author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * @brief Memory allocation for bitmap-organized raw blocks
  21. */
  22. #ifndef BITMAP_H
  23. #define BITMAP_H
  24. #include <dmmlib/config.h>
  25. #include "bitmap/bitmap_rb.h"
  26. #ifdef BITMAP_RB_ONLY
  27. /** Tries to allocate memory from a specific bitmap-organised raw block.
  28. * @param raw_block The pointer of the bitmap-organised raw block.
  29. * @param size The requested size.
  30. * @retval The address of the returned memory space.
  31. */
  32. #define dmmlib_malloc(raw_block, size) bitmap_malloc(raw_block, size)
  33. /** Frees the memory block inside of a specific bitmap-organised raw block.
  34. * @param raw_block The pointer of the bitmap-organised raw block.
  35. * @param ptr The pointer of the memory block to be freed.
  36. */
  37. #define dmmlib_free(raw_block, ptr) bitmap_free(raw_block, ptr)
  38. /**
  39. * Reallocates a memory block from a bitmap-organised raw block
  40. *
  41. * @param raw_block The pointer of the bitmap-organised raw block.
  42. * @param ptr The pointer of the memory block to be re-allocated.
  43. * @param size The requested memory size.
  44. * @retval The address to serve the request.
  45. * @retval NULL No available memory space.
  46. */
  47. #define dmmlib_realloc(raw_block, ptr, size) bitmap_realloc(raw_block, ptr, size)
  48. #endif /* BITMAP_RB_ONLY */
  49. void * bitmap_malloc(bitmap_rb_t *raw_block, size_t size);
  50. void bitmap_free(bitmap_rb_t *raw_block, void *ptr);
  51. void * bitmap_realloc(bitmap_rb_t *raw_block, void * ptr,
  52. size_t req_size);
  53. #endif /* BITMAP_H */