diff options
Diffstat (limited to 'lib/vector.c')
| -rw-r--r-- | lib/vector.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/vector.c b/lib/vector.c index 03ad3171d6..110cd2915c 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -13,10 +13,9 @@ * 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 GNU Zebra; see the file COPYING. If not, write to the Free - * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <zebra.h> @@ -25,7 +24,7 @@ #include "memory.h" DEFINE_MTYPE_STATIC(LIB, VECTOR, "Vector") -DEFINE_MTYPE( LIB, VECTOR_INDEX, "Vector index") +DEFINE_MTYPE_STATIC(LIB, VECTOR_INDEX, "Vector index") /* Initialize vector : allocate memory and return vector. */ vector @@ -44,18 +43,6 @@ vector_init (unsigned int size) } void -vector_only_wrapper_free (vector v) -{ - XFREE (MTYPE_VECTOR, v); -} - -void -vector_only_index_free (void *index) -{ - XFREE (MTYPE_VECTOR_INDEX, index); -} - -void vector_free (vector v) { XFREE (MTYPE_VECTOR_INDEX, v->index); @@ -177,6 +164,24 @@ vector_unset (vector v, unsigned int i) } } +void +vector_unset_value (vector v, void *val) +{ + size_t i; + + for (i = 0; i < v->active; i++) + if (v->index[i] == val) + { + v->index[i] = NULL; + break; + } + + if (i + 1 == v->active) + do + v->active--; + while (i && v->index[--i] == NULL); +} + /* Count the number of not emplty slot. */ unsigned int vector_count (vector v) |
