Dimitrie O. Paun wrote:
On Thu, Apr 14, 2005 at 03:05:36PM +0200, Alexandre Julliard wrote:
Actually it should be possible to handle the fault using a vectored handler, without requiring internal functions at all.
Completely untested (what do people use to test DIB handling?), but it compiles. Is something like this what you had it mind?
+/***********************************************************************
mem_area_add
- Adds a memory area to the list.
- PARAMS
base [I] Beginning address of the area
size [I] Size of the area
data [I] Data associated with the area
- */
+static struct mem_area *mem_area_add( const void *base, UINT size, void *data ) +{
- struct mem_area *area;
- EnterCriticalSection( &csMemAreas );
- area = HeapAlloc(GetProcessHeap(), 0, sizeof(*area));
You can put the HeapAlloc outside of the critical section.
- if (area)
- {
area->base = base;
area->size = size;
area->data = data;
list_add_head( &mem_areas_list, &area->entry );
- }
- LeaveCriticalSection( &csMemAreas );
- return area;
+}
+/***********************************************************************
mem_area_del
- Removes a memory area from the list.
- PARAMS
addr [I] Address
- RETURNS
Success: TRUE
Failure: FALSE
- */
+static BOOL mem_area_del( const void *addr ) +{
- struct mem_area *area;
- EnterCriticalSection( &csMemAreas );
- area = mem_area_find( addr );
- if (area) list_remove( &area->entry );
- LeaveCriticalSection( &csMemAreas );
Why don't you free area here?
- return area != NULL;
+}
/* Some of the following helper functions are duplicated in dlls/gdi/dib.c
Rob