From: Enrico Scholz Date: Sun, 3 Jul 2005 09:12:31 +0000 (+0000) Subject: added Vector_foreach*() functions X-Git-Tag: version_0_30_210~168 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd76a60f62c8b458ee8947f7afdc3b259a5fc925;p=util-vserver.git added Vector_foreach*() functions git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2113 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- 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