1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00
wine/toolkit/heap.c
Alexandre Julliard 2d159fb707 Release 940714
Thu Jul 14 17:50:45 1994  Bob Amstadt  (bob@pooh)

	* [Configure]
	Autodetects Linux version (if running Linux).

	* [loader/signal.c]
	New signals for Linux.

	* [loader/ldtlib.c]
	New structure field in sys call.

Sun Jul 10 19:31:34 1994  Olaf Flebbe  (olaf@dragon)

        * [load/resource.c] 
          fixed Memory (Resource) Leak.

        * [load/main.c] 
          fixed a printf.

Tue Jul 12 18:50:34 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)

	* [controls/desktop.c]
	Implemented desktop wallpaper (only 16 colors for now).

	* [controls/menu.c] [windows/nonclient.c]
	Preliminary work to allow multi-line menus.

	* [misc/main.c]
	No backing store on desktop window (not useful).

	* [objects/text.c]
	A few fixes to DrawText() to make underlines under mnemonic
	letters to look better.

	* [windows/graphics.c]
	More fixes to GRAPH_DrawArc(), and some fixes to Polygon().
	Implemented PolyPolygon() (partially working).

	* [windows/winpos.c]
	New function WINPOS_SendNCCalcSize().
	Cleaned up SetWindowPos() and added preliminary support for
	multi-line menus.

Mon Jul 11 19:15:51 1994  Miguel de Icaza  (miguel@sphinx)

	* [controls/edit.c]
	Changes to work as a library.

	* [if1632/callback.c] 
	Ifdefed module.

	* [if1632/relay.c]
	Changes to allow linking with WineLib.

	* [include/windows.h]
	Added macro WINELIB_UNIMP

	* [loader/library.c]
	When compiling WineLib, GetProcAddress is not implemented yet.

	* [loader/main.c]
	Added empty InitDLL when using WineLib.

	* [loader/ne_image.c]
	Some parts of the loader are needed for WineLib, ifdefed correctly

	* [misc/{audio.c,mcicda.c,mmaux.c,mmsystem.c]
	Disable compilation of module when compiling WineLib.

	* [toolkit/heap.c]
	Fixed small bug.  When passed an invalid handle WineLib would
	crash, now return NULL.

	* [toolkit/winmain.c]
	Call CreateNewTask in _WinMain.

Sun Jul 10 09:08:02 1994  David Metcalfe <david@prism.demon.co.uk>

	* [controls/edit.c] [controls/widget.c]
	More changes to improve compatibility with Windows' edit
	control.  Finished off tab stop support.

Mon Jul 11 21:05:02 MET DST 1994  Erik Bos <erik@hacktic.nl>

	* [if1632/relay.c]
	# of ordinals in shell.dll changed to 103.

	* [loader/signal.c]
	sti, cli will now be ignored.

	* [objects/brush.c]
	Added stub for GetSysColorBrush().
1994-07-15 16:04:31 +00:00

222 lines
3.6 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>
#endif
#include "windows.h"
/* 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 = malloc (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;
}
char *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);
realloc (*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);
}
char *GlobalLinearLock (HANDLE hMem)
{
return GlobalLock (hMem);
}
HANDLE GlobalLinearUnlock (HANDLE hMem)
{
return GlobalUnlock (hMem);
}
int HEAP_LocalSize ()
{
return 0;
}
int HEAP_LocalFindHeap ()
{
return 0;
}
#ifdef UNIMPLEMENTED
void *GlobalQuickAlloc(int size)
{
}
DWORD int GlobalHandle(WORD selector)
{
}
unsigned int GlobalHandleFromPointer(void *block)
{
}
#endif