Windows NT 4.0 source code leak
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.

96 lines
2.1 KiB

4 years ago
  1. /***********************************************************************
  2. * Microsoft (R) 32-Bit Incremental Linker
  3. *
  4. * Copyright (C) Microsoft Corp 1992-95. All rights reserved.
  5. *
  6. * File: memory.h
  7. *
  8. * File Comments:
  9. *
  10. * Structures & prototypes for memory management routines.
  11. *
  12. ***********************************************************************/
  13. #ifndef __MEMORY_H__
  14. #define __MEMORY_H__
  15. //
  16. // macro for permanent memory allocation
  17. //
  18. #define ALLOC_PERM(cb) \
  19. ( (cb) <= (cbTemp = cbFree) ? \
  20. cbFree -= (cb), (PVOID) (pch+cbTotal-cbTemp) : (PVOID) AllocNewBlock (cb) )
  21. extern PVOID pvBase;
  22. // size of ILK map to reserve (16M)
  23. #define ILKMAP_MAX (1024*1024*16)
  24. // Growable memory block.
  25. typedef struct BLK
  26. {
  27. BYTE *pb; // ptr to data
  28. DWORD cb; // size in use
  29. DWORD cbAlloc; // current allocated size
  30. } BLK, *PBLK;
  31. // Function Prototypes
  32. PVOID AllocNewBlock (size_t);
  33. VOID GrowBlk(PBLK, DWORD);
  34. DWORD IbAppendBlk(PBLK, const void *, DWORD);
  35. DWORD IbAppendBlkZ(PBLK pblk, DWORD cbNew);
  36. VOID FreeBlk(PBLK);
  37. __inline void InitBlk(PBLK pblk)
  38. {
  39. pblk->pb = NULL;
  40. pblk->cb = pblk->cbAlloc = 0;
  41. }
  42. // Simple heap on which blocks can be allocated but not freed (although the
  43. // whole heap can be freed).
  44. //
  45. #pragma warning(disable:4200) // Zero sized array warning
  46. typedef struct LHEAPB
  47. {
  48. struct LHEAPB *plheapbNext;
  49. DWORD cbUsed;
  50. DWORD cbFree;
  51. BYTE rgbData[];
  52. } LHEAPB;
  53. #pragma warning(default:4200)
  54. typedef struct LHEAP
  55. {
  56. LHEAPB *plheapbCur;
  57. } LHEAP;
  58. __inline VOID InitLheap(LHEAP *plheap) { plheap->plheapbCur = NULL; }
  59. VOID *PvAllocLheap(LHEAP *, DWORD);
  60. VOID FreeLheap(LHEAP *);
  61. BOOL FFreeDiskSpace(DWORD);
  62. PVOID CreateHeap(PVOID, DWORD, BOOL, DWORD *);
  63. VOID FreeHeap(VOID);
  64. VOID CloseHeap(VOID);
  65. void *Malloc(size_t);
  66. void *Calloc(size_t, size_t);
  67. char *Strdup(const char *);
  68. VOID Free(PVOID, DWORD);
  69. #if DBG
  70. VOID DumpMemMgrStats(VOID);
  71. #endif // DBG
  72. void FreePv(void *);
  73. char *SzDup(const char *);
  74. void *PvAlloc(size_t);
  75. void *PvAllocZ(size_t);
  76. void *PvRealloc(void *, size_t);
  77. #endif // __MEMORY_H__