--- libaitio/src/bufio.c 2012/03/27 14:58:12 1.3.2.1 +++ libaitio/src/bufio.c 2014/02/05 02:24:28 1.8.34.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: bufio.c,v 1.3.2.1 2012/03/27 14:58:12 misho Exp $ +* $Id: bufio.c,v 1.8.34.1 2014/02/05 02:24:28 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright 2004 - 2014 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -62,11 +62,11 @@ cf_(struct tagBufIO *buf) } if (buf->buf_mode == BUFIO_MODE_INFINIT) - free(buf->buf_base); + e_free(buf->buf_base); else if (buf->buf_unmap) buf->buf_unmap(buf); - free(buf); + e_free(buf); return 0; } @@ -157,7 +157,7 @@ sf_inf(struct tagBufIO *buf, fpos_t pos, int w) if (pos < 0) goto err; if (buf->buf_size < pos) { - b = realloc(buf->buf_base, pos); + b = e_realloc(buf->buf_base, pos); if (!b) { LOGERR; return -1; @@ -173,7 +173,7 @@ sf_inf(struct tagBufIO *buf, fpos_t pos, int w) if ((buf->buf_offset + pos) < 0) goto err; if (buf->buf_size < (buf->buf_offset + pos)) { - b = realloc(buf->buf_base, buf->buf_offset + pos); + b = e_realloc(buf->buf_base, buf->buf_offset + pos); if (!b) { LOGERR; return -1; @@ -190,7 +190,7 @@ sf_inf(struct tagBufIO *buf, fpos_t pos, int w) if ((buf->buf_size + pos) < 0) goto err; if (buf->buf_size < (buf->buf_size + pos)) { - b = realloc(buf->buf_base, buf->buf_size + pos); + b = e_realloc(buf->buf_base, buf->buf_size + pos); if (!b) { LOGERR; return -1; @@ -224,7 +224,7 @@ wf_inf(struct tagBufIO *buf, const char *dat, int siz) } if (buf->buf_offset + siz > buf->buf_size) { - b = realloc(buf->buf_base, buf->buf_offset + siz); + b = e_realloc(buf->buf_base, buf->buf_offset + siz); if (!b) { LOGERR; return -1; @@ -243,7 +243,7 @@ wf_inf(struct tagBufIO *buf, const char *dat, int siz) /* - * io_fmemopen() File buffered stream operations over memory block + * io_fmemopen() - File buffered stream operations over memory block * * @base = Base address of memory block, if =NULL Infinit length(auto-grow) * @basesize = Size of memory block @@ -260,7 +260,7 @@ io_fmemopen(void ** __restrict base, off_t basesize) return NULL; } - buf = malloc(sizeof(struct tagBufIO)); + buf = e_malloc(sizeof(struct tagBufIO)); if (!buf) { LOGERR; return NULL; @@ -268,10 +268,10 @@ io_fmemopen(void ** __restrict base, off_t basesize) memset(buf, 0, sizeof(struct tagBufIO)); if (!*base) { - *base = malloc(basesize); + *base = e_malloc(basesize); if (!*base) { LOGERR; - free(buf); + e_free(buf); return NULL; } else memset(*base, 0, basesize); @@ -309,10 +309,10 @@ io_fmemopen(void ** __restrict base, off_t basesize) if (!f) { LOGERR; if (buf->buf_mode == BUFIO_MODE_INFINIT) { - free(*base); + e_free(*base); *base = NULL; } - free(buf); + e_free(buf); return NULL; } @@ -320,7 +320,7 @@ io_fmemopen(void ** __restrict base, off_t basesize) } /* - * io_fmapopen() File buffered stream operations over MMAP block + * io_fmapopen() - File buffered stream operations over MMAP block * * @csFile = Filename for MMAP, if =NULL private MMAP block * @mode = File open mode @@ -373,7 +373,7 @@ io_fmapopen(const char *csFile, int mode, int perm, in } - buf = malloc(sizeof(struct tagBufIO)); + buf = e_malloc(sizeof(struct tagBufIO)); if (!buf) { LOGERR; munmap(base, basesize); @@ -399,7 +399,7 @@ io_fmapopen(const char *csFile, int mode, int perm, in #endif if (!f) { LOGERR; - free(buf); + e_free(buf); munmap(base, basesize); return NULL; } @@ -408,7 +408,7 @@ io_fmapopen(const char *csFile, int mode, int perm, in } /* - * io_dumbFile() Create empry or dumb file with fixed size + * io_dumbFile() - Create empry or dumb file with fixed size * * @csFile = Filename for create * @mode = File access permissions @@ -441,13 +441,13 @@ err: } /* - * io_fd2buf() Convert open file handle to buffered file I/O + * io_fd2buf() - Convert open file handle to buffered file I/O * * @fd = File handle * @mode = Permissions for new buffered file I/O * return: NULL error or open buffered file */ -inline FILE * +FILE * io_fd2buf(int fd, const char *mode) { FILE *f;