--- libelwix/src/iov.c 2021/03/19 03:01:52 1.1.2.4 +++ libelwix/src/iov.c 2021/03/21 01:31:07 1.1.2.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: iov.c,v 1.1.2.4 2021/03/19 03:01:52 misho Exp $ +* $Id: iov.c,v 1.1.2.5 2021/03/21 01:31:07 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -280,6 +280,34 @@ iov_PopPair(iovec_t * __restrict iov, char *name, size return -1; return pos; +} + +/* + * iov_FreePairs() - Free pairs/named data in iovec array + * + * @iov = iovec array + * @mustfree = data must be free before delete + * return: -1 error or 0 ok + */ +int +iov_FreePairs(iovec_t * __restrict iov, int mustfree) +{ + register int pos; + + if (!iov) + return -1; + + if (iov->iov_size < 1) + return 0; + + for (pos = 0; pos < (iov_Size(iov) & ~1); pos += 2) { + if (iov->iov_array[pos].iov_base) + iov_Delete(iov, pos, 42); + if (iov->iov_array[pos + 1].iov_base) + iov_Delete(iov, pos + 1, mustfree); + } + + return 0; } /*