Get rid of the memory allocation macros, use real functions instead.
This commit is contained in:
parent
65f7ce21d5
commit
a167c3bb68
|
@ -549,32 +549,10 @@ extern int curr_frame;
|
||||||
/* gdbproxy.c */
|
/* gdbproxy.c */
|
||||||
extern BOOL DEBUG_GdbRemote(unsigned int);
|
extern BOOL DEBUG_GdbRemote(unsigned int);
|
||||||
|
|
||||||
/* Choose your allocator! */
|
extern void *DBG_alloc(size_t size);
|
||||||
#if 1
|
extern void *DBG_realloc(void *ptr, size_t size);
|
||||||
/* this one is libc's fast one */
|
extern void DBG_free(void *ptr);
|
||||||
extern void* DEBUG_XMalloc(size_t size);
|
extern char *DBG_strdup(const char *str);
|
||||||
extern void* DEBUG_XReAlloc(void *ptr, size_t size);
|
|
||||||
extern char* DEBUG_XStrDup(const char *str);
|
|
||||||
|
|
||||||
#define DBG_alloc(x) DEBUG_XMalloc(x)
|
|
||||||
#define DBG_realloc(x,y) DEBUG_XReAlloc(x,y)
|
|
||||||
#define DBG_free(x) free(x)
|
|
||||||
#define DBG_strdup(x) DEBUG_XStrDup(x)
|
|
||||||
#else
|
|
||||||
/* this one is slow (takes 5 minutes to load the debugger on my machine),
|
|
||||||
if someone could make optimized routines so it wouldn't
|
|
||||||
take so long to load, it could be made default) */
|
|
||||||
#define DBG_alloc(x) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,x)
|
|
||||||
#define DBG_realloc(x,y) HeapReAlloc(GetProcessHeap(),0,x,y)
|
|
||||||
#define DBG_free(x) HeapFree(GetProcessHeap(),0,x)
|
|
||||||
inline static LPSTR DBG_strdup( LPCSTR str )
|
|
||||||
{
|
|
||||||
INT len = strlen(str) + 1;
|
|
||||||
LPSTR p = DBG_alloc( len );
|
|
||||||
if (p) memcpy( p, str, len );
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_STATUS_OFFSET 0x80003000
|
#define DEBUG_STATUS_OFFSET 0x80003000
|
||||||
#define DEBUG_STATUS_INTERNAL_ERROR (DEBUG_STATUS_OFFSET+0)
|
#define DEBUG_STATUS_INTERNAL_ERROR (DEBUG_STATUS_OFFSET+0)
|
||||||
|
|
|
@ -39,7 +39,7 @@ static void DEBUG_Die(const char* msg)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* DEBUG_XMalloc(size_t size)
|
void* DBG_alloc(size_t size)
|
||||||
{
|
{
|
||||||
void *res = malloc(size ? size : 1);
|
void *res = malloc(size ? size : 1);
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
|
@ -48,7 +48,7 @@ void* DEBUG_XMalloc(size_t size)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* DEBUG_XReAlloc(void *ptr, size_t size)
|
void* DBG_realloc(void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
void* res = realloc(ptr, size);
|
void* res = realloc(ptr, size);
|
||||||
if ((res == NULL) && size)
|
if ((res == NULL) && size)
|
||||||
|
@ -56,7 +56,7 @@ void* DEBUG_XReAlloc(void *ptr, size_t size)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* DEBUG_XStrDup(const char *str)
|
char* DBG_strdup(const char *str)
|
||||||
{
|
{
|
||||||
char *res = strdup(str);
|
char *res = strdup(str);
|
||||||
if (!res)
|
if (!res)
|
||||||
|
@ -64,6 +64,11 @@ char* DEBUG_XStrDup(const char *str)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DBG_free(void *ptr)
|
||||||
|
{
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
enum dbg_mode DEBUG_GetSelectorType( WORD sel )
|
enum dbg_mode DEBUG_GetSelectorType( WORD sel )
|
||||||
{
|
{
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
|
|
Loading…
Reference in New Issue