home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / MacMemoryAllocator / include / MacMemAllocator.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.2 KB  |  75 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef __MACMEMALLOCATOR__
  20. #define    __MACMEMALLOCATOR__
  21.  
  22. #ifndef NSPR20
  23. #include "prmacros.h"
  24. #include "prmacos.h"
  25. #else
  26. #include "prtypes.h"
  27. #endif
  28.  
  29. #include <stddef.h>
  30.  
  31. #include <Types.h>
  32.  
  33. typedef struct FreeMemoryStats FreeMemoryStats;
  34.  
  35. struct FreeMemoryStats {
  36.     uint32    totalHeapSize;
  37.     uint32    totalFreeBytes;
  38.     uint32    maxBlockSize;
  39. };
  40.  
  41. typedef void (*MallocHeapLowWarnProc)(void);
  42.  
  43. NSPR_BEGIN_EXTERN_C
  44.  
  45. #ifdef NSPR20
  46. typedef unsigned char (*MemoryCacheFlusherProc)(size_t size);
  47. typedef void (*PreAllocationHookProc)(void);
  48.  
  49. extern void InstallPreAllocationHook(PreAllocationHookProc newHook);
  50. extern void InstallMemoryCacheFlusher(MemoryCacheFlusherProc newFlusher);
  51.  
  52. // Entry into the memory system's cache flushing
  53. extern UInt8 CallCacheFlushers(size_t blockSize);
  54.  
  55. extern void* reallocSmaller(void* block, size_t newSize);
  56. #endif
  57.  
  58. void                memtotal ( size_t blockSize, FreeMemoryStats * stats );
  59.  
  60. size_t                memsize ( void * block );
  61.  
  62. extern Boolean        gMemoryInitialized;
  63.  
  64. void                 MacintoshInitializeMemory(void);
  65. void                CallFE_LowMemory(void);
  66. Boolean             Memory_ReserveInMacHeap(size_t spaceNeeded);
  67. Boolean             Memory_ReserveInMallocHeap(size_t spaceNeeded);
  68. Boolean             InMemory_ReserveInMacHeap();
  69. size_t                 Memory_FreeMemoryRemaining();
  70. void                 InstallGarbageCollectorCacheFlusher(const MemoryCacheFlusherProc inFlusher);
  71. void                InstallMallocHeapLowProc( MallocHeapLowWarnProc proc );
  72.  
  73. NSPR_END_EXTERN_C
  74.  
  75. #endif