Added custom memory calls for pobj internal structures.
This commit is contained in:
parent
99f85eb9c4
commit
773df6c690
3 changed files with 24 additions and 19 deletions
|
@ -1411,7 +1411,7 @@ pobj_boot_init (void)
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pobj_init (struct pobj_memfunc *ext_memfunc /* , struct pobj_memfunc *int_memfunc */)
|
pobj_init (struct pobj_memfunc *ext_memfunc, struct pobj_memfunc *int_memfunc)
|
||||||
{
|
{
|
||||||
recordid tmp_rid;
|
recordid tmp_rid;
|
||||||
int xid;
|
int xid;
|
||||||
|
@ -1446,23 +1446,10 @@ pobj_init (struct pobj_memfunc *ext_memfunc /* , struct pobj_memfunc *int_memfun
|
||||||
if (ext_memfunc->free)
|
if (ext_memfunc->free)
|
||||||
g_ext_memfunc.free = ext_memfunc->free;
|
g_ext_memfunc.free = ext_memfunc->free;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
/* Gilad, 2004-12-13: disabled in order to make project compile... */
|
|
||||||
if (int_memfunc) {
|
|
||||||
|
|
||||||
/* STOPPED HERE: don't necessarily initiate a whole new structure
|
/* Initialize internal memory manager. */
|
||||||
* for internal calls, but rather initialize XMALLOC with them. */
|
if (int_memfunc)
|
||||||
|
xmem_memfunc (int_memfunc->malloc, int_memfunc->free);
|
||||||
if (int_memfunc->malloc)
|
|
||||||
g_int_memfunc.malloc = int_memfunc->malloc;
|
|
||||||
if (int_memfunc->calloc)
|
|
||||||
g_int_memfunc.calloc = int_memfunc->calloc;
|
|
||||||
if (int_memfunc->realloc)
|
|
||||||
g_int_memfunc.realloc = int_memfunc->realloc;
|
|
||||||
if (int_memfunc->free)
|
|
||||||
g_int_memfunc.free = int_memfunc->free;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Tinit ();
|
Tinit ();
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,17 @@ struct xmem_stat {
|
||||||
#endif /* HAVE_XMEM */
|
#endif /* HAVE_XMEM */
|
||||||
|
|
||||||
|
|
||||||
|
/* Default memory calls. */
|
||||||
|
void *(*g_memfunc_malloc) (size_t) = malloc;
|
||||||
|
void (*g_memfunc_free) (void *) = free;
|
||||||
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
xmem_malloc (int mtype, char *file, int line, size_t size)
|
xmem_malloc (int mtype, char *file, int line, size_t size)
|
||||||
{
|
{
|
||||||
struct xmem *x;
|
struct xmem *x;
|
||||||
|
|
||||||
x = (struct xmem *) malloc (size + XMEM_OFFSET);
|
x = (struct xmem *) g_memfunc_malloc (size + XMEM_OFFSET);
|
||||||
if (! x)
|
if (! x)
|
||||||
exit (1);
|
exit (1);
|
||||||
|
|
||||||
|
@ -99,9 +104,21 @@ xmem_free (int mtype, void *p)
|
||||||
xmem_stats[mtype].count--;
|
xmem_stats[mtype].count--;
|
||||||
#endif /* HAVE_XMEM */
|
#endif /* HAVE_XMEM */
|
||||||
|
|
||||||
free (x);
|
g_memfunc_free (x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xmem_memfunc (void *(*memfunc_malloc)(size_t), void (*memfunc_free)(void *))
|
||||||
|
{
|
||||||
|
if (memfunc_malloc)
|
||||||
|
g_memfunc_malloc = memfunc_malloc;
|
||||||
|
if (memfunc_free)
|
||||||
|
g_memfunc_free = memfunc_free;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xmem_obj_mtype (void *p)
|
xmem_obj_mtype (void *p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@ enum {
|
||||||
|
|
||||||
void *xmem_malloc (int, char *, int, size_t);
|
void *xmem_malloc (int, char *, int, size_t);
|
||||||
void xmem_free (int, void *);
|
void xmem_free (int, void *);
|
||||||
|
int xmem_memfunc (void *(*) (size_t), void (*) (void *));
|
||||||
int xmem_obj_mtype (void *);
|
int xmem_obj_mtype (void *);
|
||||||
char *xmem_obj_file (void *);
|
char *xmem_obj_file (void *);
|
||||||
int xmem_obj_line (void *);
|
int xmem_obj_line (void *);
|
||||||
|
|
Loading…
Reference in a new issue