Leaked source code of windows server 2003
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.

97 lines
2.5 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1987-1990 **/
  4. /********************************************************************/
  5. #ifndef WINDOWS
  6. #error "Only use these APIs under Windows!"
  7. #endif
  8. /****************************************************************************\
  9. LOCHEAP2.h
  10. Local-heap management helper routines
  11. These utility routines provide access to Windows local heaps in
  12. segments other than DS (the data segment). They are exactly
  13. like the LocalInit, LocalAlloc, LocalFree, LocalLock,
  14. LocalUnlock, Local handle and LocalSize APIs, except that they
  15. act on the heap in segment wHeapDS instead of the heap in DS.
  16. These routines are used primarily by the heap management system
  17. (see heap.cxx). They are also used by the
  18. HEAP_HANDLE/ELEMENT_HANDLE module (see loclheap.hxx).
  19. USAGE:
  20. HANDLE hGlobal = GlobalAlloc( GMEM_MOVEABLE, 1024 );
  21. if ( !hGlobal )
  22. error();
  23. LPSTR lpGlobal = GlobalLock( hGlobal );
  24. if ( !lpGlobal )
  25. error();
  26. {
  27. if ( !DoLocalInit( hGlobal, 1024 ) )
  28. error();
  29. HANDLE hLocal = DoLocalAlloc( HIWORD(lpGlobal), 128 );
  30. if ( !hLocal )
  31. error();
  32. LPSTR lpLocal = DoLocalLock( HIWORD(lpGlobal), hLocal );
  33. if ( !lpLocal )
  34. error();
  35. {
  36. HANDLE hLocal2 = DoLocalHandle(
  37. HIWORD(lpGlobal), LOWORD(lpLocal) );
  38. if (hLocal2 != hLocal)
  39. error();
  40. WORD wSize = DoLocalSize( HIWORD(lpGlobal), hLocal );
  41. if ( !wSize )
  42. error();
  43. }
  44. DoLocalUnlock( HIWORD(lpGlobal), hLocal );
  45. if ( DoLocalFree( HIWORD(lpGlobal), hLocal ) )
  46. error();
  47. }
  48. GlobalUnlock( hGlobal );
  49. GlobalFree( hGlobal );
  50. FILE HISTORY:
  51. jonn 24-Jan-1991 Created
  52. jonn 21-Mar-1991 Code review changes from 2/20/91 (attended
  53. by JonN, RustanL, ?)
  54. \****************************************************************************/
  55. #ifndef _LOCHEAP2_H_
  56. #define _LOCHEAP2_H_
  57. BOOL DoLocalInit(WORD wHeapDS, WORD wBytes);
  58. HANDLE DoLocalAlloc(WORD wHeapDS, WORD wFlags, WORD wBytes);
  59. HANDLE DoLocalFree(WORD wHeapDS, HANDLE handleFree);
  60. LPSTR DoLocalLock(WORD wHeapDS, HANDLE handleLocal);
  61. VOID DoLocalUnlock(WORD wHeapDS, HANDLE handleLocal);
  62. HANDLE DoLocalHandle(WORD wHeapDS, WORD wMem);
  63. WORD DoLocalSize(WORD wHeapDS, HANDLE handleLocal);
  64. #endif // _LOCHEAP2_H_