single_allocator.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 single_allocator.h
  19. * \author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * \date September, 2011
  21. * Basic structures needed for the dmmlib allocator.
  22. */
  23. #ifndef SINGLE_ALLOCATOR_H
  24. #define SINGLE_ALLOCATOR_H
  25. #include <dmmlib/pool.h>
  26. /* In case stdlib.h is used, there is no need to redeclare
  27. * malloc() and free()
  28. */
  29. /**
  30. * Allocates size bytes by using the system's allocator.
  31. * \param size Requested allocation size in bytes.
  32. */
  33. void *dmmlib_malloc(size_t size);
  34. /**
  35. * De-allocates the memory space pointed to by ptr.
  36. * \param ptr The pointer to memory to free.
  37. */
  38. void dmmlib_free(void *ptr);
  39. /**
  40. * Try to change the size of an allocation
  41. * \param ptr The pointer to the data part of the original memory block.
  42. * \param size The new desired size of the block.
  43. *
  44. * \return The pointer to the data part of the memory block which
  45. * has the new, desired size.
  46. */
  47. void * dmmlib_realloc(void *ptr, size_t size);
  48. /** Global variable storing allocator's settings */
  49. allocator_t systemallocator;
  50. #endif /* SINGLE_ALLOCATOR_H */