www.pudn.com > helpview.zip > Winmem.h, change:1997-10-15,size:3987b


/* 
  
Copyright 1997 Willows Software, Inc.  
 
This library is free software; you can redistribute it and/or 
modify it under the terms of the GNU Library General Public License as 
published by the Free Software Foundation; either version 2 of the 
License, or (at your option) any later version. 
 
This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
Library General Public License for more details. 
 
You should have received a copy of the GNU Library General Public 
License along with this library; see the file COPYING.LIB.  If 
not, write to the Free Software Foundation, Inc., 675 Mass Ave, 
Cambridge, MA 02139, USA. 
 
*/ 
 
/************************************************************************* 
* 
* WINMEM.H 
* General memory routines.      
* 
* Author: Paul E. Kissel 
* 
**************************************************************************/ 
 
#ifndef WINMEM_H 
#define WINMEM_H 
 
 
/************************************* 
* 
*  System Includes 
* 
**************************************/ 
#include <windows.h> 
 
 
/*********************************** 
** 
**  Shared Defines 
** 
***********************************/ 
 
#if 0 
/* Element list and list info. */ 
typedef struct tagMEMORYPAGE 
{ 
  HGLOBAL hGlobal;             /* Handle to page's memory space. */ 
  void * GlobalPtr;      /* Locked page's memory space. */ 
  UINT    Segment;             /* SELECTOROF( GlobalPtr ). */ 
} 
MEMORYPAGE; 
typedef MEMORYPAGE * FPMEMORYPAGE; 
#endif 
 
/* Element list and list info. */ 
typedef struct tagMEMORYPAGE 
{ 
  HGLOBAL hGlobal;             /* Handle to page's memory space. */ 
  BYTE * GlobalPtr;      /* Locked page's memory space. */ 
  WORD wBytesFree; 
} 
MEMORYPAGE; 
typedef MEMORYPAGE * FPMEMORYPAGE; 
 
/* Memory list and list info. */ 
typedef struct tagMEMORYLIST 
{ 
  WORD wNumPages;              /* Number of page's in list (used and not used). */ 
  WORD wPagesInUse;            /* Number of page's in list that are being used. */ 
  HGLOBAL hPageList;           /* Handle to the list of pages. */ 
  FPMEMORYPAGE TopPagePtr;     /* Pointer to the first page in the list. */ 
} 
MEMORYLIST; 
typedef MEMORYLIST * FPMEMORYLIST; 
 
 
/************************************* 
* 
*  Allocate global memory of a certain size and trap error. 
* 
**************************************/ 
BOOL GlobalAllocMem( HWND hWnd, HGLOBAL * hGlobal, DWORD dwSize  ); 
 
 
/************************************* 
* 
*  Reallocate global memory of a certain size and trap error. 
* 
**************************************/ 
BOOL GlobalReAllocMem( HWND hWnd, HGLOBAL * hGlobal, DWORD dwNewSize  ); 
 
 
/***************************************** 
** 
**  Allocates a buffer and copies string's 
**  data into the buffer. 
** 
*****************************************/ 
HGLOBAL CopyString( HWND hErrorWnd, char * fpString ); 
 
 
#ifdef DEBUGGINGON 
void MyGlobalFree( HGLOBAL hGlobal ); 
#else 
#define MyGlobalFree GlobalFree 
#endif 
 
/****************************** Local Heap Functions ******************************/ 
 
/*************************************************** 
* 
* Creates a MEMORYLIST structure that contains a  
* list of memory pages.  
* 
****************************************************/ 
BOOL AllocMemoryList( HGLOBAL * hMemoryList ); 
 
 
/*************************************************** 
* 
* Free a MEMORYLIST structure that contains a  
* list of memory pages.  
* 
****************************************************/ 
void FreeMemoryList( HGLOBAL * hMemoryList );  
 
 
/*************************************************** 
* 
* Allocates memory inside of a page of memory.  
* 
****************************************************/ 
/* LPVOID MyAlloc( FPMEMORYLIST fpMemoryList, WORD wSize ); */ 
BYTE * MyAlloc( FPMEMORYLIST fpMemoryList, WORD wSize ); 
 
 
#endif