Fri Nov 3 20:08:17 1995 Alexandre Julliard <julliard@sunsite.unc.edu> * [configure.in] Attempt to check for -li386 on NetBSD. Please test this. Mon Oct 30 12:40:32 EST 1995 Jim Peterson <jspeter@birch.ee.vt.edu> * [*/*] Eliminated various warnings with either explicit casts or more accurate variable/parameter declarations (e.g. INT instead of short or WORD). Changed macros 'min' and 'max' to 'MIN' and 'MAX', since they're macros. * [controls/edit.c] [windows/defdlg.c] Added '#ifdef SUPERFLUOUS_FUNCTIONS' wrappers around function definition of EDIT_KeyVScrollDoc, EDIT_TextLineNumber, and DEFDLG_FindDefButton to avoid warnings. * [controls/button.c] [controls/scroll.c] [windows/defwnd.c] [windows/message.c] [windows/nonclient.c] Converted MAKEPOINT macro call to manual conversion. * [include/windows.h] For WINELIB32, structures POINT, SIZE, and RECT have LONG members instead of INT. This also invalidates the macro MAKEPOINT(), which is not supported in Win32. Also defined the POINTS structure (SHORT members) and the MAKEPOINTS macro. * [misc/commdlg.c] Changed a lot of 'strcpy' calls to 'strncpy' calls. I'm desperate to find this memory bug, and this should be done anyway. * [controls/edit.c] Well, the alteration mentioned above didn't do it, but #ifdef'ing out a few lines in EDIT_ClearText did. This leads to bugs, but for now, it's better than bizzare memory troubles. * [toolkit/miscstubs.c] Removed warning messages in GLOBAL_CreateBlock(), GLOBAL_FreeBlock(), and RELAY32_GetEntryPoint(). These are the most popular warnings, and their current implementation seems fine. Sat Oct 28 09:39:18 1995 Jochen Karrer <cip307@wpax01.Physik.Uni-Wuerzburg.DE> * [objects/cursoricon.c] Fix for "broken" X servers that invert masked cursor colors. Fri Oct 27 19:27:21 1995 Alex Korobka <alex@phm6.pharm.sunysb.edu> * [windows/dialog.c] [windows/nonclient.c] Remove unnecessary items from the system menu. Thu Oct 26 05:03:03 MET 1995 Philippe De Muyter <phdm@info.ucl.ac.be> * [objects/color.c] [objects/palette.c] Make GetNearestColor return a RGB value instead of a pixel value. Wed Oct 25 23:33:39 1995 Martin von Loewis <loewis@informatik.hu-berlin.de> * [controls/desktop.c][controls/menu.c][include/menu.h] Changed WORD parameters to UINT parameters. * [include/wintypes.h] Made UINT 32bit for WINELIB. * [loader/main.c] Disabled RELAY32_Init and MODULE_Init for WINELIB. * [misc/main.c] Assume CPU386 for WINELIB. * [rc/winerc] add_popup: set MF_POPUP flag on menu item. * [toolkit/Makefile.in][toolkit/hello3.c][toolkit/hello3res.c] Add resource demo hello3 for WINELIB. New file README.resources. * [toolkit/miscstubs.c] Add a case for 17. Tue Oct 17 15:13:10 IST 1995 Itai Nahshon <nahshon@vnet.ibm.com> * [loader/module.c] Do not append .exe if the file name already has an extension. * [misc/profile.c] Avoid creating a file with a junk name if a .ini file does not exist. * [if1632/gdi.spec] [if1632/user.spec] [if1632/dummy.c] Added a lot of dummy stubs for Windows Hebrew version. Tue Oct 17 01:03:24 1995 William Magro <wmagro@tc.cornell.edu> * [controls/button.c] Fix for buttons with no label. * [controls/combo.c][controls/listbox.c] Fixes for scrollbar positioning. Now disappears correctly for short lists. * [controls/edit.c] Handle memory allocation differently when building as library. * [controls/static] Don't destroy old icon before drawing new icon. (Fixes landscape/ portrait toggle icon in print dialog.) * [if1632/gdi.spec] New functions SetMetaFileBits and GetMetaFileBits * [include/sysmetrics.h] [windows/sysmetrics.c] Add support for GetSystemMetrics(SM_CMETRICS) == SM_CMETRICS * [include/windows.h] META_EXTTEXTOUT, not META_SETTEXTOUT define GetCurrentTime as GetTickCount (for wine library) * [loader/main.c] Don't initialize built-in modules in wine library * [memory/local.c] LocalReAlloc was defined incorrectly. Swap flags and size arguments. * [misc/main.c] Always report CPUTYPE=4 to wine library. * [objects/dib.c] RLE8 images were missing top line when decompressed. * [objects/metafile.c] SetMetaFileBits and GetMetaFileBits implemented. Works when called from winhelp. More testing needed. Various memory leaks plugged. Various other bug fixes. New metafile operations added in PlayMetaFileRecord: CreatePalette, SetTextAlign, SelectPalette, SetMapperFlags, RealizePalette, ExtTextOut, Escape. Testing needed. * [toolkit/heap.c] LocalUnLock changed to LocalUnlock Sun Oct 15 21:55:33 1995 Anand Kumria <akumria@ozemail.com.au> * [misc/winsock.c] Return the correct error number, for host lookup operations. Also, correct the problem with send_message. Fri Oct 13 19:04:35 1995 Morten Welinder <terra@diku.dk> * [Makefile.in] Using nm's built-in sorting. * [*/*.c] Use xmalloc for malloc and xrealloc for realloc in all ungarded cases. * [debugger/dbg.y] Handle C-like expressions. Clean-up. * [debugger/debug.l] Lots of new tokens for expressions. * [debugger/info.c] Implement "list" command for disassembling. * [misc/ole2nls.c] Implement more Danish stuff. Fri Oct 6 10:39:39 1995 Ram'on Garc'ia <ramon@ie3.clubs.etsit.upm.es> * [loader/module.c] Updated self-loading modules to support for new 32 bit stack frames.
384 lines
6.3 KiB
C
384 lines
6.3 KiB
C
/*
|
|
* Memory alllocation for the Wine Library toolkit
|
|
*
|
|
* Copyright (C) 1994 Miguel de Icaza
|
|
*
|
|
* All the memory management is being done by the libc malloc and friends.
|
|
*/
|
|
|
|
/* #ifndef __STDC__ */
|
|
#include <malloc.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
/* #endif */
|
|
#include "windows.h"
|
|
#include "xmalloc.h"
|
|
|
|
#ifdef WINELIB16
|
|
|
|
/* Controls the blocks per handle table */
|
|
#define MAXBLOCKS 1024
|
|
|
|
static char Copyright [] = "Copyright (C) 1994 Miguel de Icaza";
|
|
|
|
typedef struct handle_table {
|
|
struct handle_table *next;
|
|
void *blocks [MAXBLOCKS];
|
|
} handle_table_t;
|
|
|
|
static handle_table_t handle_table;
|
|
|
|
static void **HEAP_GetFreeSlot (HANDLE *hNum)
|
|
{
|
|
handle_table_t *table, *last;
|
|
int i, j;
|
|
|
|
for (table = &handle_table, j = 0; table; table = table->next, j++){
|
|
for (i = 0; i < MAXBLOCKS; i++)
|
|
if (!table->blocks [i])
|
|
goto AssignBlock;
|
|
last = table;
|
|
}
|
|
|
|
/* No free slots */
|
|
last->next = xmalloc (sizeof (handle_table_t));
|
|
table = last->next;
|
|
memset (table, 0, sizeof (handle_table_t));
|
|
i = 0;
|
|
|
|
AssignBlock:
|
|
*hNum = j*MAXBLOCKS+i;
|
|
return &table->blocks [i];
|
|
}
|
|
|
|
static void HEAP_Handle_is_Zero ()
|
|
{
|
|
printf ("Warning: Handle is Zero, segmentation fault comming\n");
|
|
}
|
|
|
|
static void **HEAP_FindSlot (HANDLE hNum)
|
|
{
|
|
handle_table_t *table = &handle_table;
|
|
int i, j;
|
|
|
|
if (!hNum)
|
|
HEAP_Handle_is_Zero ();
|
|
|
|
hNum--;
|
|
for (j = hNum; j > MAXBLOCKS; j -= MAXBLOCKS){
|
|
table = table->next;
|
|
if (!table) return 0;
|
|
}
|
|
return &table->blocks [hNum%MAXBLOCKS];
|
|
}
|
|
|
|
HANDLE LocalAlloc (WORD flags, WORD bytes)
|
|
{
|
|
void *m;
|
|
void **slot;
|
|
HANDLE hMem;
|
|
|
|
slot = HEAP_GetFreeSlot (&hMem);
|
|
if (flags & LMEM_WINE_ALIGN)
|
|
m = memalign (4, bytes);
|
|
else
|
|
m = malloc (bytes);
|
|
if (m){
|
|
*slot = m;
|
|
if (flags & LMEM_ZEROINIT)
|
|
bzero (m, bytes);
|
|
|
|
#ifdef DEBUG_HEAP
|
|
printf ("Handle %d [%d] = %p\n", hMem+1, bytes, m);
|
|
#endif
|
|
return hMem+1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
WORD LocalCompact (WORD min_free)
|
|
{
|
|
return min_free;
|
|
}
|
|
|
|
WORD LocalFlags (HANDLE hMem)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
HANDLE LocalFree (HANDLE hMem)
|
|
{
|
|
void **m = HEAP_FindSlot (hMem);
|
|
|
|
free (*m);
|
|
*m = 0;
|
|
return 0;
|
|
}
|
|
|
|
BOOL LocalInit (WORD segment, WORD start, WORD end)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
WORD LocalLock (HANDLE hMem)
|
|
{
|
|
void **m = HEAP_FindSlot (hMem);
|
|
#ifdef DEBUG_HEAP
|
|
printf (">%d->%p\n", hMem, *m);
|
|
#endif
|
|
return m ? *m : 0;
|
|
}
|
|
|
|
HANDLE LocalReAlloc (HANDLE hMem, WORD flags, WORD bytes)
|
|
{
|
|
void **m = HEAP_FindSlot (hMem);
|
|
|
|
xrealloc (*m, bytes);
|
|
}
|
|
|
|
WORD LocalSize (HANDLE hMem)
|
|
{
|
|
/* Not implemented yet */
|
|
}
|
|
|
|
|
|
BOOL LocalUnlock (HANDLE hMem)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
HANDLE GlobalAlloc (WORD flags, DWORD size)
|
|
{
|
|
return LocalAlloc (flags, size);
|
|
}
|
|
|
|
HANDLE GlobalFree (HANDLE hMem)
|
|
{
|
|
return LocalFree (hMem);
|
|
}
|
|
|
|
char *GlobalLock (HANDLE hMem)
|
|
{
|
|
return LocalLock (hMem);
|
|
}
|
|
|
|
BOOL GlobalUnlock (HANDLE hMem)
|
|
{
|
|
return LocalUnlock (hMem);
|
|
}
|
|
|
|
WORD GlobalFlags (HANDLE hMem)
|
|
{
|
|
return LocalFlags (hMem);
|
|
}
|
|
|
|
DWORD GlobalSize (HANDLE hMem)
|
|
{
|
|
return LocalSize (hMem);
|
|
}
|
|
|
|
DWORD GlobalCompact(DWORD desired)
|
|
{
|
|
if (desired)
|
|
return desired;
|
|
else
|
|
return 0x01000000; /* Should check the available core. */
|
|
}
|
|
|
|
HANDLE GlobalReAlloc(HANDLE hMem, DWORD new_size, WORD flags)
|
|
{
|
|
if (!(flags & GMEM_MODIFY))
|
|
return LocalReAlloc (hMem, new_size, flags);
|
|
}
|
|
|
|
int HEAP_LocalSize ()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int HEAP_LocalFindHeap ()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#ifdef UNIMPLEMENTED
|
|
|
|
DWORD int GlobalHandle(WORD selector)
|
|
{
|
|
}
|
|
|
|
#endif
|
|
|
|
#else /* WINELIB16 */
|
|
|
|
#ifdef DEBUG_HEAP
|
|
static void* LastTwenty[20]={ 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0 };
|
|
|
|
void CheckMem(void* f)
|
|
{
|
|
int i;
|
|
|
|
for(i=0; i<20; i++)
|
|
{
|
|
if(LastTwenty[i]==f)
|
|
LastTwenty[i]=NULL;
|
|
else if(LastTwenty[i])
|
|
if( *((int*)LastTwenty[i]) != 0x12345678 ||
|
|
*(((int*)LastTwenty[i])+1) != 0x0fedcba9 )
|
|
fprintf(stderr,"memory corrupted at %p\n",LastTwenty[i]);
|
|
}
|
|
fflush(stderr);
|
|
}
|
|
|
|
void NewMem(void* n)
|
|
{
|
|
int i;
|
|
for(i=0; i<20; i++)
|
|
if(!LastTwenty[i])
|
|
{
|
|
LastTwenty[i]=n;
|
|
return;
|
|
}
|
|
for(i=0; i<20; i++)
|
|
LastTwenty[i]=LastTwenty[i+1];
|
|
LastTwenty[4]=n;
|
|
}
|
|
#endif
|
|
|
|
HANDLE LocalAlloc (WORD flags, WORD bytes)
|
|
{
|
|
HANDLE m;
|
|
#ifdef DEBUG_HEAP
|
|
bytes+=2*sizeof(int);
|
|
#endif
|
|
|
|
if (flags & LMEM_WINE_ALIGN)
|
|
m = memalign (4, bytes);
|
|
else
|
|
m = malloc (bytes);
|
|
if (m){
|
|
if (flags & LMEM_ZEROINIT)
|
|
bzero (m, bytes);
|
|
}
|
|
#ifdef DEBUG_HEAP
|
|
CheckMem(NULL);
|
|
*((int*) m)=0x12345678;
|
|
*(((int*) m)+1)=0x0fedcba9;
|
|
fprintf(stderr,"%p malloc'd\n",m); fflush(stderr);
|
|
NewMem(m);
|
|
return (HANDLE) (((int*)m)+2);
|
|
#endif
|
|
return m;
|
|
}
|
|
|
|
WORD LocalCompact (WORD min_free)
|
|
{
|
|
return min_free;
|
|
}
|
|
|
|
WORD LocalFlags (HANDLE hMem)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
HANDLE LocalFree (HANDLE hMem)
|
|
{
|
|
#ifdef DEBUG_HEAP
|
|
hMem=(HANDLE) (((int*)hMem)-2);
|
|
CheckMem(hMem);
|
|
fprintf(stderr,"%p free-ing...",hMem);
|
|
if( *((int*)hMem) != 0x12345678 ||
|
|
*(((int*)hMem)+1) != 0x0fedcba9 )
|
|
fprintf(stderr,"memory corrupted...");
|
|
else
|
|
{
|
|
*((int*)hMem) = 0x9abcdef0;
|
|
*(((int*)hMem)+1) = 0x87654321;
|
|
}
|
|
fflush(stderr);
|
|
#endif
|
|
free(hMem);
|
|
#ifdef DEBUG_HEAP
|
|
fprintf(stderr,"free'd\n"); fflush(stderr);
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
BOOL LocalInit (HANDLE segment, WORD start, WORD end)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
LPVOID LocalLock (HANDLE hMem)
|
|
{
|
|
return hMem;
|
|
}
|
|
|
|
HANDLE LocalReAlloc (HANDLE hMem, WORD flags, WORD bytes)
|
|
{
|
|
#ifdef DEBUG_HEAP
|
|
LocalFree(hMem);
|
|
return LocalAlloc(flags,bytes);
|
|
#endif
|
|
return realloc(hMem, bytes);
|
|
}
|
|
|
|
WORD LocalSize (HANDLE hMem)
|
|
{
|
|
/* Not implemented yet */
|
|
return 0;
|
|
}
|
|
|
|
|
|
BOOL LocalUnlock (HANDLE hMem)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
HANDLE GlobalAlloc (WORD flags, DWORD size)
|
|
{
|
|
return LocalAlloc (flags, size);
|
|
}
|
|
|
|
HANDLE GlobalFree (HANDLE hMem)
|
|
{
|
|
return LocalFree (hMem);
|
|
}
|
|
|
|
LPVOID GlobalLock (HGLOBAL hMem)
|
|
{
|
|
return LocalLock (hMem);
|
|
}
|
|
|
|
BOOL GlobalUnlock (HANDLE hMem)
|
|
{
|
|
return LocalUnlock (hMem);
|
|
}
|
|
|
|
WORD GlobalFlags (HANDLE hMem)
|
|
{
|
|
return LocalFlags (hMem);
|
|
}
|
|
|
|
DWORD GlobalSize (HANDLE hMem)
|
|
{
|
|
return LocalSize (hMem);
|
|
}
|
|
|
|
DWORD GlobalCompact(DWORD desired)
|
|
{
|
|
if (desired)
|
|
return desired;
|
|
else
|
|
return 0x01000000; /* Should check the available core. */
|
|
}
|
|
|
|
HANDLE GlobalReAlloc(HANDLE hMem, DWORD new_size, WORD flags)
|
|
{
|
|
if (!(flags & GMEM_MODIFY))
|
|
return LocalReAlloc (hMem, new_size, flags);
|
|
else
|
|
return hMem;
|
|
}
|
|
|
|
#endif
|