/*
Dynamic memory handling functions for reading data into 
memory blocks and writing it out etc

*/

#ifndef DMEM_HEAD
#define DMEM_HEAD done

/* dmem library */
typedef struct DMEMLIST {char *data; int size; int used; struct DMEMLIST *next;} Dmemlist;
typedef struct DMEM {Dmemlist *d; Dmemlist *last; int len; int blocksize;} Dmem;
int dmem_new(Dmem **d);
int dmem_free(Dmem **d);
int dmem_write(Dmem *d, char *data, int len);
int dmem_fwrite(FILE *f, Dmem *d);
//int dmem_tofile(Dmem *d, FILE *f, char *reason);
int dmem_printf(Dmem *d,const char * arg_list, ...);
int dmem_readfile(Dmem *d, FILE *f);
int dmem_insert(Dmem *d, char *data, int len);

#endif
