USRHOOKS.CPP 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**********************************************************************
  2. module: USRHOOKS.C
  3. author: James R. Dos‚
  4. phone: (214)-271-1365 Ext #221
  5. date: July 26, 1994
  6. This module contains cover functions for operations the library
  7. needs that may be restricted by the calling program. This code
  8. is left public for you to modify.
  9. **********************************************************************/
  10. #include "debug4g.h"
  11. #include "usrhooks.h"
  12. #include "resource.h"
  13. #include <memcheck.h>
  14. /*---------------------------------------------------------------------
  15. Function: USRHOOKS_GetMem
  16. Allocates the requested amount of memory and returns a pointer to
  17. its location, or NULL if an error occurs. NOTE: pointer is assumed
  18. to be dword aligned.
  19. ---------------------------------------------------------------------*/
  20. int USRHOOKS_GetMem( void **ptr, unsigned long size )
  21. {
  22. void *memory;
  23. memory = Resource::Alloc( size );
  24. if ( memory == NULL )
  25. return( USRHOOKS_Error );
  26. *ptr = memory;
  27. dprintf("USRHOOKS_GetMem allocated %d bytes at %p\n", size, memory);
  28. return( USRHOOKS_Ok );
  29. }
  30. /*---------------------------------------------------------------------
  31. Function: USRHOOKS_FreeMem
  32. Deallocates the memory associated with the specified pointer.
  33. ---------------------------------------------------------------------*/
  34. int USRHOOKS_FreeMem( void *ptr )
  35. {
  36. if ( ptr == NULL )
  37. return( USRHOOKS_Error );
  38. dprintf("USRHOOKS_FreeMem at %p\n",ptr);
  39. Resource::Free( ptr );
  40. return( USRHOOKS_Ok );
  41. }