CVS: winex/dlls/ntdll heap.c, 1.9, 1.10 heapfuncs.h, NONE, 1.1 heapinit.c, NONE, 1.1 Makefile.in, 1.5, 1.6 oldheap.c, NONE, 1.1

[email protected]
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/ntdll heap.c,1.9,1.10 heapfuncs.h,NONE,1.1 heapinit.c,NONE,1.1 Makefile.in,1.5,1.6 oldheap.c,NONE,1.1Update of /var/lib/cvsd/cvsroot/winex/dlls/ntdll
In directory agravaine:/tmp/cvs-serv4083/dlls/ntdll

Modified Files:
	heap.c Makefile.in 
Added Files:
	heapfuncs.h heapinit.c oldheap.c 
Log Message:
- add a new memory allocator based on ptmalloc3 and make it the default (at least for now for testing)
- to disable, add "NewAllocator"="N" to the [Wine] section of your config file


Index: heap.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/heap.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- heap.c	14 Mar 2005 17:14:05 -0000	1.9
+++ heap.c	30 Mar 2007 18:17:21 -0000	1.10
@@ -1,118 +1,42 @@
 /*
  * Win32 heap functions
  *
- * Copyright 1996 Alexandre Julliard
- * Copyright 1998 Ulrich Weigand
+ * Copyright 2006 TransGaming Technologies
  */
 
 #include "config.h"
 
-#include <assert.h>
[...1793 lines suppressed...]
-ULONG WINAPI RtlGetProcessHeaps( ULONG count, HANDLE *heaps )
+ULONG NewRtlGetProcessHeaps (ULONG count, HANDLE *heaps)
 {
-    DWORD total;
-    HEAP *ptr;
-
-    if (!processHeap) return 0;  /* should never happen */
-    total = 1;  /* main heap */
-    RtlLockHeap( processHeap );
-    for (ptr = firstHeap; ptr; ptr = ptr->next) total++;
-    if (total <= count)
-    {
-        *heaps++ = (HANDLE)processHeap;
-        for (ptr = firstHeap; ptr; ptr = ptr->next) *heaps++ = (HANDLE)ptr;
-    }
-    RtlUnlockHeap( processHeap );
-    return total;
+   FIXME ("(): stub\n");
+   return 0;
 }

--- NEW FILE: heapfuncs.h ---
/*
 * Win32 heap function initialization
 *
 * Copyright 2006 TransGaming Technologies
 */

#ifndef _WINE_HEAPFUNCS_H
#define _WINE_HEAPFUNCS_H

extern HANDLE OldRtlCreateHeap (ULONG flags, PVOID addr, ULONG reserveSize,
                                ULONG commitSize, PVOID unknown,
                                PRTL_HEAP_DEFINITION definition);
extern HANDLE OldRtlDestroyHeap (HANDLE heap);
extern PVOID OldRtlAllocateHeap (HANDLE heap, ULONG flags, ULONG size);
extern BOOLEAN OldRtlFreeHeap (HANDLE heap, ULONG flags, PVOID ptr);
extern PVOID OldRtlReAllocateHeap (HANDLE heap, ULONG flags, PVOID ptr,
                                   ULONG size);
extern ULONG OldRtlCompactHeap (HANDLE heap, ULONG flags);
extern BOOLEAN OldRtlLockHeap (HANDLE heap);
extern BOOLEAN OldRtlUnlockHeap (HANDLE heap);
extern ULONG OldRtlSizeHeap (HANDLE heap, ULONG flags, PVOID ptr);
extern BOOLEAN OldRtlValidateHeap (HANDLE heap, ULONG flags, PCVOID block);
extern NTSTATUS OldRtlWalkHeap (HANDLE heap, PVOID entry_ptr);
extern ULONG OldRtlGetProcessHeaps (ULONG count, HANDLE *heaps);


extern HANDLE NewRtlCreateHeap (ULONG flags, PVOID addr, ULONG reserveSize,
                                ULONG commitSize, PVOID unknown,
                                PRTL_HEAP_DEFINITION definition);
extern HANDLE NewRtlDestroyHeap (HANDLE heap);
extern PVOID NewRtlAllocateHeap (HANDLE heap, ULONG flags, ULONG size);
extern BOOLEAN NewRtlFreeHeap (HANDLE heap, ULONG flags, PVOID ptr);
extern PVOID NewRtlReAllocateHeap (HANDLE heap, ULONG flags, PVOID ptr,
                                   ULONG size);
extern ULONG NewRtlCompactHeap (HANDLE heap, ULONG flags);
extern BOOLEAN NewRtlLockHeap (HANDLE heap);
extern BOOLEAN NewRtlUnlockHeap (HANDLE heap);
extern ULONG NewRtlSizeHeap (HANDLE heap, ULONG flags, PVOID ptr);
extern BOOLEAN NewRtlValidateHeap (HANDLE heap, ULONG flags, PCVOID block);
extern NTSTATUS NewRtlWalkHeap (HANDLE heap, PVOID entry_ptr);
extern ULONG NewRtlGetProcessHeaps (ULONG count, HANDLE *heaps);

#endif

--- NEW FILE: heapinit.c ---
/*
 * Win32 heap function initialization
 *
 * Copyright 2006 TransGaming Technologies
 */

#include "config.h"
#include "winternl.h"
#include "heapfuncs.h"


static BOOL gUseNewAllocator = 1;


void HEAP_Init (BOOL UseNewAllocator)
{
   gUseNewAllocator = UseNewAllocator;
}


HANDLE WINAPI RtlCreateHeap (ULONG flags, PVOID addr, ULONG reserveSize,
                             ULONG commitSize, PVOID unknown,
                             PRTL_HEAP_DEFINITION definition)
{
   if (gUseNewAllocator)
      return NewRtlCreateHeap (flags, addr, reserveSize, commitSize, unknown,
                               definition);
   else
      return OldRtlCreateHeap (flags, addr, reserveSize, commitSize, unknown,
                               definition);
}


HANDLE WINAPI RtlDestroyHeap (HANDLE heap)
{
   if (gUseNewAllocator)
      return NewRtlDestroyHeap (heap);
   else
      return OldRtlDestroyHeap (heap);
}


PVOID WINAPI RtlAllocateHeap (HANDLE heap, ULONG flags, ULONG size)
{
   if (gUseNewAllocator)
      return NewRtlAllocateHeap (heap, flags, size);
   else
      return OldRtlAllocateHeap (heap, flags, size);
}


BOOLEAN WINAPI RtlFreeHeap (HANDLE heap, ULONG flags, PVOID ptr)
{
   if (gUseNewAllocator)
      return NewRtlFreeHeap (heap, flags, ptr);
   else
      return OldRtlFreeHeap (heap, flags, ptr);
}


PVOID WINAPI RtlReAllocateHeap (HANDLE heap, ULONG flags, PVOID ptr,
                                ULONG size)
{
   if (gUseNewAllocator)
      return NewRtlReAllocateHeap (heap, flags, ptr, size);
   else
      return OldRtlReAllocateHeap (heap, flags, ptr, size);
}


ULONG WINAPI RtlCompactHeap (HANDLE heap, ULONG flags)
{
   if (gUseNewAllocator)
      return NewRtlCompactHeap (heap, flags);
   else
      return OldRtlCompactHeap (heap, flags);
}


BOOLEAN WINAPI RtlLockHeap (HANDLE heap)
{
   if (gUseNewAllocator)
      return NewRtlLockHeap (heap);
   else
      return OldRtlLockHeap (heap);
}


BOOLEAN WINAPI RtlUnlockHeap (HANDLE heap)
{
   if (gUseNewAllocator)
      return NewRtlUnlockHeap (heap);
   else
      return OldRtlUnlockHeap (heap);
}


ULONG WINAPI RtlSizeHeap (HANDLE heap, ULONG flags, PVOID ptr)
{
   if (gUseNewAllocator)
      return NewRtlSizeHeap (heap, flags, ptr);
   else
      return OldRtlSizeHeap (heap, flags, ptr);
}


BOOLEAN WINAPI RtlValidateHeap (HANDLE heap, ULONG flags, PCVOID block)
{
   if (gUseNewAllocator)
      return NewRtlValidateHeap (heap, flags, block);
   else
      return OldRtlValidateHeap (heap, flags, block);
}


NTSTATUS WINAPI RtlWalkHeap (HANDLE heap, PVOID entry_ptr)
{
   if (gUseNewAllocator)
      return NewRtlWalkHeap (heap, entry_ptr);
   else
      return OldRtlWalkHeap (heap, entry_ptr);
}


ULONG WINAPI RtlGetProcessHeaps (ULONG count, HANDLE *heaps)
{
   if (gUseNewAllocator)
      return NewRtlGetProcessHeaps (count, heaps);
   else
      return OldRtlGetProcessHeaps (count, heaps);
}

Index: Makefile.in
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/Makefile.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.in	29 Mar 2007 14:09:47 -0000	1.5
+++ Makefile.in	30 Mar 2007 18:17:21 -0000	1.6
@@ -15,10 +15,12 @@
 	error.c \
 	file.c \
 	heap.c \
+	heapinit.c \
 	large_int.c \
 	loader.c \
 	misc.c \
 	nt.c \
+	oldheap.c \
 	om.c \
 	reg.c \
 	rtl.c \
@@ -48,7 +50,8 @@
 	$(TOPOBJDIR)/ole/ole.o \
 	$(TOPOBJDIR)/relay32/relay32.o \
 	$(TOPOBJDIR)/scheduler/scheduler.o \
-	$(TOPOBJDIR)/win32/win32.o
+	$(TOPOBJDIR)/win32/win32.o \
+	$(TOPOBJDIR)/libs/ptmalloc3/dmalloc.o
 
 SUBDIRS = \
 	$(TOPOBJDIR)/files \
@@ -61,7 +64,8 @@
 	$(TOPOBJDIR)/ole \
 	$(TOPOBJDIR)/relay32 \
 	$(TOPOBJDIR)/scheduler \
-	$(TOPOBJDIR)/win32
+	$(TOPOBJDIR)/win32 \
+	$(TOPOBJDIR)/libs/ptmalloc3
 
 @MAKE_DLL_RULES@
 

--- NEW FILE: oldheap.c ---
/*
 * Win32 heap functions
 *
 * Copyright 1996 Alexandre Julliard
 * Copyright 1998 Ulrich Weigand
 */

#include "config.h"

#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "winternl.h"
#include "wine/winbase16.h"
#include "winbase.h"
#include "winerror.h"
#include "winnt.h"
[...1441 lines suppressed...]
/***********************************************************************
 *           RtlGetProcessHeaps    (NTDLL.@)
 */
ULONG OldRtlGetProcessHeaps( ULONG count, HANDLE *heaps )
{
    DWORD total;
    HEAP *ptr;

    if (!processHeap) return 0;  /* should never happen */
    total = 1;  /* main heap */
    RtlLockHeap( processHeap );
    for (ptr = firstHeap; ptr; ptr = ptr->next) total++;
    if (total <= count)
    {
        *heaps++ = (HANDLE)processHeap;
        for (ptr = firstHeap; ptr; ptr = ptr->next) *heaps++ = (HANDLE)ptr;
    }
    RtlUnlockHeap( processHeap );
    return total;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.