From dd76a60f62c8b458ee8947f7afdc3b259a5fc925 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Sun, 3 Jul 2005 09:12:31 +0000 Subject: [PATCH] added Vector_foreach*() functions git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2113 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/ensc_vector/Makefile-files | 1 + util-vserver/ensc_vector/vector-foreach.c | 34 +++++++++++++++++++++++++++++++ util-vserver/ensc_vector/vector.h | 4 ++++ util-vserver/ensc_vector/vector.hc | 9 ++++++++ 4 files changed, 48 insertions(+) create mode 100644 util-vserver/ensc_vector/vector-foreach.c diff --git a/util-vserver/ensc_vector/Makefile-files b/util-vserver/ensc_vector/Makefile-files index b2d9aa7..6fb511a 100644 --- a/util-vserver/ensc_vector/Makefile-files +++ b/util-vserver/ensc_vector/Makefile-files @@ -16,6 +16,7 @@ ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ENSC_VECTOR_SRCS = ensc_vector/vector-clear.c \ + ensc_vector/vector-foreach.c \ ensc_vector/vector-free.c \ ensc_vector/vector-init.c \ ensc_vector/vector-insert.c \ diff --git a/util-vserver/ensc_vector/vector-foreach.c b/util-vserver/ensc_vector/vector-foreach.c new file mode 100644 index 0000000..ea9db5f --- /dev/null +++ b/util-vserver/ensc_vector/vector-foreach.c @@ -0,0 +1,34 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "vector.h" + +void +Vector_foreach(struct Vector *vec, void (*func)(void *, void *), void *data) +{ + char * ptr = Vector_begin(vec); + char * const end = Vector_end(vec); + size_t const step = vec->elem_size; + + for (; ptr