memory.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] Web: www.q12.org *
  5. * *
  6. * This library is free software; you can redistribute it and/or *
  7. * modify it under the terms of EITHER: *
  8. * (1) The GNU Lesser General Public License as published by the Free *
  9. * Software Foundation; either version 2.1 of the License, or (at *
  10. * your option) any later version. The text of the GNU Lesser *
  11. * General Public License is included with this library in the *
  12. * file LICENSE.TXT. *
  13. * (2) The BSD-style license that is included with this library in *
  14. * the file LICENSE-BSD.TXT. *
  15. * *
  16. * This library is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  19. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  20. * *
  21. *************************************************************************/
  22. /* this comes from the `reuse' library. copy any changes back to the source */
  23. #ifndef _ODE_MEMORY_H_
  24. #define _ODE_MEMORY_H_
  25. #include <ode/odeconfig.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /* function types to allocate and free memory */
  30. typedef void * dAllocFunction (size_t size);
  31. typedef void * dReallocFunction (void *ptr, size_t oldsize, size_t newsize);
  32. typedef void dFreeFunction (void *ptr, size_t size);
  33. /* set new memory management functions. if fn is 0, the default handlers are
  34. * used. */
  35. ODE_API void dSetAllocHandler (dAllocFunction *fn);
  36. ODE_API void dSetReallocHandler (dReallocFunction *fn);
  37. ODE_API void dSetFreeHandler (dFreeFunction *fn);
  38. /* get current memory management functions */
  39. ODE_API dAllocFunction *dGetAllocHandler (void);
  40. ODE_API dReallocFunction *dGetReallocHandler (void);
  41. ODE_API dFreeFunction *dGetFreeHandler (void);
  42. /* allocate and free memory. */
  43. ODE_API void * dAlloc (size_t size);
  44. ODE_API void * dRealloc (void *ptr, size_t oldsize, size_t newsize);
  45. ODE_API void dFree (void *ptr, size_t size);
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif