--- libaitio/src/Attic/tools.c 2012/05/19 00:11:58 1.14 +++ libaitio/src/Attic/tools.c 2012/07/03 08:51:05 1.15 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: tools.c,v 1.14 2012/05/19 00:11:58 misho Exp $ +* $Id: tools.c,v 1.15 2012/07/03 08:51:05 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -123,7 +123,7 @@ io_UnquotStr(char * __restrict psLine) return 0; if (*psLine == '"' || *psLine == '\'') { - str = strdup(psLine + 1); + str = io_strdup(psLine + 1); for (pos = str, flg = 0; *pos; flg = ('\\' == *pos), pos++) { if (!flg && *pos == *psLine) { *pos = 0; @@ -131,7 +131,7 @@ io_UnquotStr(char * __restrict psLine) break; } } - free(str); + io_free(str); return 1; } @@ -143,7 +143,7 @@ io_UnquotStr(char * __restrict psLine) * * @psLine = Text string * @lineLen = Length of Text string - * return: NULL nothing to do or error; !=0 Allocated new converted data without term\0 (must be free) + * return: NULL nothing to do or error; !=0 Allocated new converted data without term\0 (must be io_free) */ inline u_char * io_Ch2Hex(u_char *psLine, int lineLen) @@ -155,7 +155,7 @@ io_Ch2Hex(u_char *psLine, int lineLen) if (!psLine || !*psLine || !lineLen) return NULL; - str = malloc(lineLen / 2); + str = io_malloc(lineLen / 2); if (!str) { LOGERR; return NULL; @@ -176,7 +176,7 @@ io_Ch2Hex(u_char *psLine, int lineLen) * * @psLine = Text string * @lineLen = Length of Text string - * return: NULL nothing to do or error; !=0 Allocated new converted string(must be free) + * return: NULL nothing to do or error; !=0 Allocated new converted string(must be io_free) */ inline char * io_Hex2Ch(u_char *psLine, int lineLen) @@ -187,7 +187,7 @@ io_Hex2Ch(u_char *psLine, int lineLen) if (!psLine || !*psLine || !lineLen) return NULL; - str = malloc(lineLen * 2 + 1); + str = io_malloc(lineLen * 2 + 1); if (!str) { LOGERR; return NULL; @@ -207,7 +207,7 @@ io_Hex2Ch(u_char *psLine, int lineLen) * io_CopyEnv() - Copy environment to new environment array; * * @oldenv = Environment array - * return: NULL error; !=NULL Allocated new environment array(must be free) + * return: NULL error; !=NULL Allocated new environment array(must be io_free) */ char ** io_CopyEnv(const char **oldenv) @@ -226,7 +226,7 @@ io_CopyEnv(const char **oldenv) num++; /* create and copy new environment */ - newenv = calloc(num + 1, sizeof(char*)); + newenv = io_calloc(num + 1, sizeof(char*)); if (!newenv) { LOGERR; return NULL; @@ -235,7 +235,7 @@ io_CopyEnv(const char **oldenv) for (i = 0; oldenv[i]; i++) if (*strchr(oldenv[i], '=')) { - *el = strdup(oldenv[i]); + *el = io_strdup(oldenv[i]); el++; } *el = NULL; @@ -248,7 +248,7 @@ io_CopyEnv(const char **oldenv) * * @psProg = Program name for execute * @oldarg = Arguments array - * return: NULL error; !=NULL Allocated execution array(must be free) + * return: NULL error; !=NULL Allocated execution array(must be io_free) */ char ** io_ExecArgs(const char *psProg, const char **oldarg) @@ -265,18 +265,18 @@ io_ExecArgs(const char *psProg, const char **oldarg) for (num = 0; oldarg[num]; num++); /* create and copy new arguments */ - newarg = calloc(num + 2, sizeof(char*)); + newarg = io_calloc(num + 2, sizeof(char*)); if (!newarg) { LOGERR; return NULL; } else el = newarg; - *el = strdup(psProg); + *el = io_strdup(psProg); el++; for (i = 0; oldarg[i]; i++, el++) - *el = strdup(oldarg[i]); + *el = io_strdup(oldarg[i]); *el = NULL; return newarg; @@ -296,8 +296,8 @@ io_FreeNullTerm(char *** __restrict arr) if (arr && *arr) { a = *arr; while (a && *a) - free(*a++); - free(*arr); + io_free(*a++); + io_free(*arr); *arr = NULL; } } @@ -323,7 +323,7 @@ io_Path2File(const char * __restrict csArgs, char * __ if (psPath && !pathLen) return -1; - psBuf = strdup(csArgs); + psBuf = io_strdup(csArgs); if (!psBuf) { LOGERR; return -1; @@ -333,7 +333,7 @@ io_Path2File(const char * __restrict csArgs, char * __ if (!pos) { strlcpy(psFile, psBuf, fileLen); - free(psBuf); + io_free(psBuf); return 1; } else *pos++ = 0; @@ -342,7 +342,7 @@ io_Path2File(const char * __restrict csArgs, char * __ if (psPath) strlcpy(psPath, psBuf, pathLen); - free(psBuf); + io_free(psBuf); return 2; }