/*****************************************************************************\
* Copyright (c) 2002-2004 Pelle Johansson. *
* All rights reserved. *
* *
* This file is part of the moftpd package. Use and distribution of *
* this software is governed by the terms in the file LICENCE, which *
* should have come with this package. *
\*****************************************************************************/
/* $moftpd: memory.h 1251 2005-03-06 22:24:29Z morth $ */
#ifndef _MEMORY_H
#define _MEMORY_H
enum
{
pNextParent = 0, pNextChild, pParent, pChild,
#ifdef MEMORY_LOCATION
pLocation,
#endif
pNumLinkLinks,
pNextTemp = 0, pNumTempLinks
};
struct memdata;
struct memhash;
typedef union memory
{
union memory *link;
struct memdata *data;
struct memhash *hash;
void **loc;
} memory_t;
typedef struct memdata
{
memory_t firstParent, firstChild;
void (*deallocator)(void *ptr);
struct memdata *next;
unsigned int isHashed:1, mark:1;
} memdata_t;
typedef struct memhash
{
memdata_t **bucket;
memdata_t *next;
} memhash_t;
void mem_init (void);
void *talloc(size_t sz);
void *trealloc(void *ptr, size_t sz);
void tfree_all(void);
char *tstring(const char *str);
void *palloc(size_t sz, void *parent, void (*deallocator)(void *ptr)
#ifdef MEMORY_LOCATION
, void **loc
#endif
);
void *prealloc(void *ptr, size_t sz);
void *pattach(void *child, void *parent
#ifdef MEMORY_LOCATION
, void **loc
#endif
);
void *padopt(void *child, void *oldparent, void *newparent
#ifdef MEMORY_LOCATION
, void **newloc
#endif
);
void *prootify (void *ptr);
void pfree(void *child, void *parent);
void *pchild(const void *parent, const void *prevChild);
int plinked (const void *child, const void *parent);
int pnparents (const void *child);
void *proot(
#ifdef MEMORY_LOCATION
void **loc
#else
void
#endif
);
char *pstring(const char *str, void *parent
#ifdef MEMORY_LOCATION
void **loc
#endif
);
#endif /*_MEMORY_H*/
syntax highlighted by Code2HTML, v. 0.9.1