dmmlib.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2012 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 dmmlib.h
  19. * @author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * @date August 2012
  21. * @brief Memory allocation and de-allocation functions.
  22. *
  23. * This file should be used when linking directly dmmlib to your project.
  24. * Warning: In case you also use the C standard library, do not forget to link
  25. * dmmlib first or else your project will use C standard library's
  26. * implementations for dynamic memory management.
  27. */
  28. #ifndef DMMLIB_H
  29. #define DMMLIB_H
  30. #include <dmmlib/config.h>
  31. #include <dmmlib/allocator.h>
  32. /** Global variable storing allocator's settings */
  33. allocator_t systemallocator;
  34. #if !defined _STDLIB_H && !defined _STDLIB_H_
  35. /**
  36. * Allocates size bytes by using the system's allocator.
  37. * @param size Requested allocation size in bytes.
  38. *
  39. * @return The pointer to the memory location.
  40. */
  41. void * malloc(size_t size);
  42. /**
  43. * De-allocates the memory space pointed to by ptr.
  44. * @param ptr The pointer to memory to free.
  45. */
  46. void free(void *ptr);
  47. /**
  48. * Try to change the size of an allocation
  49. * @param ptr The pointer to the data part of the original memory block.
  50. * @param size The new desired size of the block.
  51. *
  52. * @return The pointer to the new memory location.
  53. */
  54. void * realloc(void *ptr, size_t size);
  55. /**
  56. * Allocate enough space for a number of objects of a specific size.
  57. * @param count The number of objects.
  58. * @param size The size of one object.
  59. *
  60. * @return A pointer to the allocated memory.
  61. */
  62. void * calloc(size_t count, size_t size);
  63. #ifdef WITH_MEMALIGN
  64. #include <dmmlib/memalign.h>
  65. #endif /* WITH_MEMALIGN */
  66. #endif /* ! STDLIB_H */
  67. #endif /* DMMLIB_H */