Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: MEMORY.CXX
  7. //
  8. //----------------------------------------------------------------------------
  9. #include "dswarn.h"
  10. #include <ADs.hxx>
  11. //+---------------------------------------------------------------------------
  12. //
  13. // Function: ADsAlloc, public
  14. //
  15. // Synopsis: Global allocator for ADs.
  16. //
  17. // Effects: Keeps track of the most recent heap allocation in each
  18. // thread. This information is used to determine when to
  19. // unlink CUnwindable objects.
  20. //
  21. // Arguments: [size] -- Size of the memory to allocate.
  22. //
  23. // Returns: A pointer to the allocated memory.
  24. //
  25. // Modifies: _pLastNew in _exceptioncontext.
  26. //
  27. //----------------------------------------------------------------------------
  28. void*
  29. ADsAlloc( size_t size )
  30. {
  31. void *p;
  32. p = (void *)LocalAlloc( LMEM_FIXED, size );
  33. return ( p );
  34. }
  35. //+---------------------------------------------------------------------------
  36. //
  37. // Function: ADsFree
  38. //
  39. // Synopsis: Matches the ADsAlloc above
  40. //
  41. // Arguments: [p] -- The pointer to delete.
  42. //
  43. // Requires: [p] was called with ADsFree
  44. //
  45. // Derivation: Never override.
  46. //
  47. //----------------------------------------------------------------------------
  48. void
  49. ADsFree ( void * p )
  50. {
  51. if( p == NULL ){
  52. return;
  53. }
  54. if( LocalFree( (HLOCAL)p ) != NULL )
  55. Win4Assert(!"Bad ptr for operator delete");
  56. }