-- fix: make memmgr compile cleanly
-- remove some unneeded code
This commit is contained in:
@@ -101,8 +101,6 @@ EXPORT void MemPrivatePoolReturnEntryDirect(void *PoolHandle, void *PoolEntry, c
|
||||
#define MemPrivatePoolGetEntry(p) MemPrivatePoolGetEntryDirect((p), __FILE__, __LINE__)
|
||||
#define MemPrivatePoolReturnEntry(p, e) MemPrivatePoolReturnEntryDirect((p), (e), __FILE__, __LINE__);
|
||||
|
||||
EXPORT BOOL MemPrivatePoolZeroCallback(void *buffer, void *clientData);
|
||||
|
||||
|
||||
/** memstack.c **/
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
StrictCompile()
|
||||
|
||||
add_library(bongomemmgr SHARED
|
||||
allocator.c
|
||||
pools.c
|
||||
|
||||
@@ -7,24 +7,36 @@
|
||||
EXPORT void *
|
||||
MemMallocDirect(size_t Size, const char *SourceFile, unsigned long SourceLine)
|
||||
{
|
||||
UNUSED_PARAMETER_REFACTOR(SourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(SourceLine);
|
||||
|
||||
return g_malloc(Size);
|
||||
}
|
||||
|
||||
EXPORT void *
|
||||
MemMalloc0Direct(size_t size, const char *sourceFile, unsigned long sourceLine)
|
||||
{
|
||||
UNUSED_PARAMETER_REFACTOR(sourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(sourceLine);
|
||||
|
||||
return g_malloc0(size);
|
||||
}
|
||||
|
||||
EXPORT void *
|
||||
MemReallocDirect(void *Source, size_t Size, const char *SourceFile, unsigned long SourceLine)
|
||||
{
|
||||
UNUSED_PARAMETER_REFACTOR(SourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(SourceLine);
|
||||
|
||||
return g_realloc(Source, Size);
|
||||
}
|
||||
|
||||
EXPORT char *
|
||||
MemStrdupDirect(const char *StrSource, const char *SourceFile, unsigned long SourceLine)
|
||||
{
|
||||
UNUSED_PARAMETER_REFACTOR(SourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(SourceLine);
|
||||
|
||||
return MemStrndupDirect(StrSource, strlen(StrSource), SourceFile, SourceLine);
|
||||
}
|
||||
|
||||
@@ -32,6 +44,9 @@ EXPORT char *
|
||||
MemStrndupDirect(const char *StrSource, int n, const char *SourceFile, unsigned long SourceLine)
|
||||
{
|
||||
char *new;
|
||||
UNUSED_PARAMETER_REFACTOR(SourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(SourceLine);
|
||||
|
||||
|
||||
new = MemMallocDirect(n + 1, SourceFile, SourceLine);
|
||||
memcpy(new, StrSource, n);
|
||||
@@ -43,6 +58,9 @@ MemStrndupDirect(const char *StrSource, int n, const char *SourceFile, unsigned
|
||||
EXPORT void
|
||||
MemFreeDirect(void *Source, const char *SourceFile, unsigned long SourceLine)
|
||||
{
|
||||
UNUSED_PARAMETER_REFACTOR(SourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(SourceLine);
|
||||
|
||||
g_free(Source);
|
||||
}
|
||||
|
||||
|
||||
+2
-115
@@ -24,118 +24,8 @@
|
||||
|
||||
#include <memmgr.h>
|
||||
|
||||
/* Library Definitions */
|
||||
#if !defined(offsetof)
|
||||
#define offsetof(s, m) ((size_t)&(((s *)0)->m))
|
||||
#endif
|
||||
|
||||
#define SUFFIX_OFFSET offsetof(MemPoolEntry, suffix)
|
||||
|
||||
#define POOL128_ALLOC_SIZE (128)
|
||||
#define POOL256_ALLOC_SIZE (256)
|
||||
#define POOL512_ALLOC_SIZE (512)
|
||||
#define POOL1KB_ALLOC_SIZE (1024)
|
||||
#define POOL2KB_ALLOC_SIZE (2 * 1024)
|
||||
#define POOL4KB_ALLOC_SIZE (4 * 1024)
|
||||
#define POOL8KB_ALLOC_SIZE (8 * 1024)
|
||||
#define POOL16KB_ALLOC_SIZE (16 * 1024)
|
||||
#define POOL32KB_ALLOC_SIZE (32 * 1024)
|
||||
#define POOL64KB_ALLOC_SIZE (64 * 1024)
|
||||
#define POOL128KB_ALLOC_SIZE (128 * 1024)
|
||||
#define POOL256KB_ALLOC_SIZE (256 * 1024)
|
||||
#define POOL512KB_ALLOC_SIZE (512 * 1024)
|
||||
#define POOL1MB_ALLOC_SIZE (1024 * 1024)
|
||||
#define POOL2MB_ALLOC_SIZE (2 * 1024 * 1024)
|
||||
#define POOL4MB_ALLOC_SIZE (4 * 1024 * 1024)
|
||||
|
||||
/* 1111111111222222222233333333334444444444555555555566666666667777777777
|
||||
1234567890123456789012345678901234567890123456789012345678901234567890123456789 */
|
||||
|
||||
#define LIBMSGREADY "Bongo Memmory Manager Ready\r\n"
|
||||
#define LIBMSGREADY_LEN 31
|
||||
|
||||
#define LIBMSGBYE "Bongo Memmory Manager Signing Off\r\n"
|
||||
#define LIBMSGBYE_LEN 37
|
||||
|
||||
#define LIBMSGBADCOMMAND "NO: Invalid command.\r\n"
|
||||
#define LIBMSGBADCOMMAND_LEN 22
|
||||
|
||||
#define LIBMSGALLOCFAILED "NO: Allocation request failed.\r\n"
|
||||
#define LIBMSGALLOCFAILED_LEN 32
|
||||
|
||||
#define LIBMSGACTION "OK: Action performed.\r\n"
|
||||
#define LIBMSGACTION_LEN 23
|
||||
|
||||
/* Can't do LIBMSGHELP_LEN because of VCS revision insertion */
|
||||
#if defined(MEMMGR_DEBUG)
|
||||
#if defined(NETWARE) || defined(LIBC)
|
||||
#define LIBMSGHELP "Bongo Memory Manager $Revision: 1.2 $ Help\r\n" \
|
||||
"--------------------------------------------------------------------------------\r\n" \
|
||||
"CALLOC CONFIG ENTDBG FREE MALLOC POOL POOLS QUIT\r\n" \
|
||||
"REALLOC\r\n" \
|
||||
"--------------------------------------------------------------------------------\r\n"
|
||||
#else /* !defined(NETWARE) || defined(LIBC) */
|
||||
#define LIBMSGHELP "Bongo Memory Manager $Revision: 1.2 $ Help\r\n" \
|
||||
"--------------------------------------------------------------------------------\r\n" \
|
||||
"CALLOC CONFIG FREE MALLOC POOL POOLS QUIT REALLOC \r\n" \
|
||||
"--------------------------------------------------------------------------------\r\n"
|
||||
#endif /* defined(NETWARE) || defined(LIBC) */
|
||||
#else /* defined(MEMMGR_DEBUG) */
|
||||
#define LIBMSGHELP "Bongo Memory Manager $Revision: 1.2 $ Help\r\n" \
|
||||
"--------------------------------------------------------------------------------\r\n" \
|
||||
"CONFIG POOL POOLS QUIT\r\n" \
|
||||
"--------------------------------------------------------------------------------\r\n"
|
||||
#endif /* defined(MEMMGR_DEBUG) */
|
||||
|
||||
#define LIBMSGHELPENTDBG "HELP: ENTDBG - Enter the NetWare Debugger.\r\n"
|
||||
#define LIBMSGHELPENTDBG_LEN 44
|
||||
|
||||
#define LIBMSGHELPCONFIG "HELP: CONFIG - Return current library configuration.\r\n"
|
||||
#define LIBMSGHELPCONFIG_LEN 54
|
||||
|
||||
/* 1111111111222222222233333333334444444444555555555566666666667777777777
|
||||
1234567890123456789012345678901234567890123456789012345678901234567890123456789 */
|
||||
#define LIBMSGHELPPOOL "HELP: POOL <IDENT> - Return current state for the pool matching IDENT.\r\n"
|
||||
#define LIBMSGHELPPOOL_LEN 72
|
||||
|
||||
#define LIBMSGHELPPOOLS "HELP: POOLS - Return current state for all pools.\r\n"
|
||||
#define LIBMSGHELPPOOLS_LEN 51
|
||||
|
||||
#define LIBMSGHELPQUIT "HELP: QUIT - Close session.\r\n"
|
||||
#define LIBMSGHELPQUIT_LEN 29
|
||||
|
||||
#define LIBMSGHELPCALLOC "HELP: CALLOC <COUNT> <SIZE> - Allocate and memset COUNT * SIZE octets to 0.\r\n"
|
||||
#define LIBMSGHELPCALLOC_LEN 77
|
||||
|
||||
#define LIBMSGHELPFREE "HELP: FREE - Release last successful allocation.\r\n"
|
||||
#define LIBMSGHELPFREE_LEN 50
|
||||
|
||||
#define LIBMSGHELPMALLOC "HELP: MALLOC <COUNT> - Allocate COUNT octets.\r\n"
|
||||
#define LIBMSGHELPMALLOC_LEN 47
|
||||
|
||||
#define LIBMSGHELPREALLOC "HELP: REALLOC <COUNT> - Reallocate previous allocation to COUNT octets.\r\n"
|
||||
#define LIBMSGHELPREALLOC_LEN 73
|
||||
|
||||
#define LIBMSGHELPSTRDUP "HELP: STRDUP <STRING> - Allocate octets to store STRING.\r\n"
|
||||
#define LIBMSGHELPSTRDUP_LEN 58
|
||||
|
||||
#define LIBMSGHELPUNKNOWN "ERR: Unknown command \"%s\".\r\n"
|
||||
|
||||
#define PENTRY_FLAG_NON_POOLABLE (1 << 0)
|
||||
#define PENTRY_FLAG_EXTREME_ENTRY (1 << 1)
|
||||
#define PENTRY_FLAG_PRIVATE_ENTRY (1 << 2)
|
||||
#define PENTRY_FLAG_INUSE (1 << 3)
|
||||
#define PENTRY_FLAG_INDIRECT_ALLOC (1 << 4)
|
||||
|
||||
#define PCONTROL_FLAG_DYNAMIC (1 << 0)
|
||||
#define PCONTROL_FLAG_CONFIG_CHANGED (1 << 1)
|
||||
#define PCONTROL_FLAG_CONFIG_SAVED (1 << 2)
|
||||
#define PCONTROL_FLAG_INITIALIZED (1 << 3)
|
||||
#define PCONTROL_FLAG_DO_NOT_SAVE (1 << 4)
|
||||
|
||||
#define PENTRY_FLAGS_ACCEPTABLE_FREE (PENTRY_FLAG_NON_POOLABLE | PENTRY_FLAG_EXTREME_ENTRY | PENTRY_FLAG_PRIVATE_ENTRY | PENTRY_FLAG_INDIRECT_ALLOC)
|
||||
|
||||
/* Library Structures */
|
||||
#if 0
|
||||
typedef struct _MemPoolEntry {
|
||||
struct _MemPoolEntry *next; /* Next pooled entry */
|
||||
struct _MemPoolEntry *previous; /* Previous pooled entry */
|
||||
@@ -152,10 +42,6 @@ typedef struct _MemPoolEntry {
|
||||
unsigned long line; /* Source code line */
|
||||
} source;
|
||||
|
||||
union {
|
||||
double dummy; /* Force appropriate alignment */
|
||||
unsigned char suffix[4]; /* Base pointer for allocations */
|
||||
};
|
||||
} MemPoolEntry;
|
||||
|
||||
typedef struct _MemPoolControl {
|
||||
@@ -200,6 +86,7 @@ typedef struct _MemPoolControl {
|
||||
MemPoolEntry *end;
|
||||
} base;
|
||||
} MemPoolControl;
|
||||
#endif
|
||||
|
||||
#if defined(MEMMGR_DEBUG)
|
||||
#define MEMMGR_FLAG_REPORT_LEAKS (1 << 0)
|
||||
|
||||
+13
-8
@@ -3,14 +3,6 @@
|
||||
#include <glib.h>
|
||||
#include "memmgrp.h"
|
||||
|
||||
EXPORT BOOL
|
||||
MemPrivatePoolZeroCallback(void *buffer, void *clientData)
|
||||
{
|
||||
memset(buffer, 0, (int)(clientData));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
struct MemPoolPrivateRef {
|
||||
size_t size;
|
||||
PoolEntryCB on_alloc;
|
||||
@@ -22,6 +14,11 @@ EXPORT void *
|
||||
MemPrivatePoolAlloc(unsigned char *name, size_t AllocationSize, unsigned int MinAllocCount, unsigned int MaxAllocCount, BOOL Dynamic, BOOL Temporary, PoolEntryCB allocCB, PoolEntryCB freeCB, void *clientData)
|
||||
{
|
||||
struct MemPoolPrivateRef *ref;
|
||||
UNUSED_PARAMETER_REFACTOR(name);
|
||||
UNUSED_PARAMETER_REFACTOR(MinAllocCount);
|
||||
UNUSED_PARAMETER_REFACTOR(MaxAllocCount);
|
||||
UNUSED_PARAMETER_REFACTOR(Dynamic);
|
||||
UNUSED_PARAMETER_REFACTOR(Temporary);
|
||||
|
||||
ref = g_new0(struct MemPoolPrivateRef, 1);
|
||||
ref->size = AllocationSize;
|
||||
@@ -44,6 +41,8 @@ MemPrivatePoolGetEntryDirect(void *PoolHandle, const char *SourceFile, unsigned
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
struct MemPoolPrivateRef *ref = (struct MemPoolPrivateRef *)PoolHandle;
|
||||
UNUSED_PARAMETER_REFACTOR(SourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(SourceLine);
|
||||
|
||||
void *new = g_slice_alloc0(ref->size);
|
||||
|
||||
@@ -64,6 +63,8 @@ EXPORT void
|
||||
MemPrivatePoolReturnEntryDirect(void *PoolHandle, void *Source, const char *SourceFile, unsigned long SourceLine)
|
||||
{
|
||||
struct MemPoolPrivateRef *ref = (struct MemPoolPrivateRef *)PoolHandle;
|
||||
UNUSED_PARAMETER_REFACTOR(SourceFile);
|
||||
UNUSED_PARAMETER_REFACTOR(SourceLine);
|
||||
|
||||
if (ref->on_free != NULL) {
|
||||
PoolEntryCB callback = ref->on_free;
|
||||
@@ -78,6 +79,8 @@ MemPrivatePoolReturnEntryDirect(void *PoolHandle, void *Source, const char *Sour
|
||||
EXPORT BOOL
|
||||
MemoryManagerOpen(const unsigned char *AgentName)
|
||||
{
|
||||
UNUSED_PARAMETER_REFACTOR(AgentName);
|
||||
|
||||
// do we need this?
|
||||
return(TRUE);
|
||||
}
|
||||
@@ -85,6 +88,8 @@ MemoryManagerOpen(const unsigned char *AgentName)
|
||||
EXPORT BOOL
|
||||
MemoryManagerClose(const unsigned char *AgentName)
|
||||
{
|
||||
UNUSED_PARAMETER_REFACTOR(AgentName);
|
||||
|
||||
// do we need this?
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user