"Fossies" - the Fresh Open Source Software Archive

Member "rbldnsd-0.998/mempool.h" (14 Mar 2013, 1057 Bytes) of package /linux/misc/dns/rbldnsd-0.998.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mempool.h" see the Fossies "Dox" file reference documentation.

    1 /* memory pool #include file
    2  */
    3 
    4 #ifndef _MEMPOOL_H_INCLUDED
    5 #define _MEMPOOL_H_INCLUDED
    6 
    7 struct mempool_chunk;
    8 
    9 struct mempool { /* free-once memory pool.  All members are private */
   10   struct mempool_chunk *mp_chunk; /* list of chunks with free space */
   11   struct mempool_chunk *mp_fullc; /* list of full chunks */
   12   unsigned mp_nallocs;      /* number of allocs so far */
   13   unsigned mp_datasz;       /* size of allocated data */
   14   const char *mp_lastbuf;   /* last allocated string */
   15   unsigned mp_lastlen;      /* length of lastbuf */
   16 };
   17 
   18 void mp_init(struct mempool *mp);
   19 void *mp_alloc(struct mempool *mp, unsigned size, int align);
   20 #define mp_talloc(mp, type) ((type*)mp_alloc((mp), sizeof(type), 1))
   21 void mp_free(struct mempool *mp);
   22 char *mp_strdup(struct mempool *mp, const char *str);
   23 void *mp_memdup(struct mempool *mp, const void *buf, unsigned len);
   24 const char *mp_dstrdup(struct mempool *mp, const char *str);
   25 const void *mp_dmemdup(struct mempool *mp, const void *buf, unsigned len);
   26 /* dstrdup, dmemdup trying to pack repeated strings together */
   27 
   28 #endif