File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / iftop / vector.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 16:57:34 2012 UTC (12 years, 3 months ago) by misho
Branches: iftop, MAIN
CVS tags: v1_0rc4, v0_17p0, v0_17, HEAD
iftop

    1: /*
    2:  * vector.h:
    3:  * simple vectors
    4:  *
    5:  * Copyright (c) 2001 Chris Lightfoot. All rights reserved.
    6:  *
    7:  * $Id: vector.h,v 1.1.1.1 2012/02/21 16:57:34 misho Exp $
    8:  *
    9:  */
   10: 
   11: #ifndef __VECTOR_H_ /* include guard */
   12: #define __VECTOR_H_
   13: 
   14: typedef union _item {
   15:     void *v;
   16:     long l;
   17: } item;
   18: 
   19: #define _inline inline
   20: 
   21: static _inline item item_long(const long l) { item u; u.l = l; return u; }
   22: static _inline item item_ptr(void *const v) { item u; u.v = v; return u; }
   23: 
   24: typedef struct _vector{
   25:     item *ary;
   26:     size_t n, n_used;
   27: } *vector;
   28: 
   29: vector vector_new(void);
   30: void vector_delete(vector);
   31: void vector_delete_free(vector);
   32: 
   33: void  vector_push_back(vector, const item);
   34: void  vector_pop_back(vector);
   35: item vector_back(const vector);
   36: 
   37: item *vector_remove(vector, item *t);
   38: 
   39: void  vector_reallocate(vector, const size_t n);
   40: 
   41: /* A macro to iterate over a vector */
   42: #define vector_iterate(_v, _t)  for ((_t) = (_v)->ary; (_t) < (_v)->ary + (_v)->n_used; ++(_t))
   43: 
   44: #endif /* __VECTOR_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>