single_allocator.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/heap.h>
  26. /* In case stdlib.h is used, there is no need to redeclare
  27. * malloc() and free()
  28. */
  29. #ifndef __malloc_and_calloc_defined
  30. /**
  31. * Allocates size bytes by using the system's allocator.
  32. * \param size Requested allocation size in bytes.
  33. */
  34. void * malloc(size_t size);
  35. /**
  36. * De-allocates the memory space pointed to by ptr.
  37. * \param ptr The pointer to memory to free.
  38. */
  39. void free(void *ptr);
  40. /**
  41. * Try to change the size of an allocation
  42. * \param ptr The pointer to the data part of the original memory block.
  43. * \param size The new desired size of the block.
  44. *
  45. * \return The pointer to the data part of the memory block which
  46. * has the new, desired size.
  47. */
  48. void * realloc(void *ptr, size_t size);
  49. #endif /* __malloc_and_calloc_defined */
  50. /** Global variable storing allocator's settings */
  51. allocator_t systemallocator;
  52. #endif /* SINGLE_ALLOCATOR_H */