plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

vec.h (834B)


      1 AUTOLIB(vec)
      2 
      3 #define Vecadd(p) Vecadd_((Type*)p, sizeof(*p[0]))
      4 #define Vecaddv(p, a, type) *(type*)Vecadd(p) = a
      5 #define Vecclose(p) Vecclose_((Type*)p, sizeof(*p[0]))
      6 #define Vecdel(p, n) Vecdel_((Type*)p, sizeof(*p[0]), n)
      7 #define Vecinit(p) Vecinit_((Type*)p, sizeof(*p[0]), NULL, NULL)
      8 #define Vecinitf(p, i, c) Vecinit_((Type*)p, sizeof(*p[0]), i, c)
      9 #define Vecinsure(p, n) Vecinsure_((Type*)p, sizeof(*p[0]), n);
     10 #define Veczero(p) Veczero_((Type*)p, sizeof(*p[0]));
     11 
     12 typedef void *Type;
     13 
     14 typedef struct {
     15 	void (*init)();
     16 	void (*close)();
     17 	ulong n;
     18 	ulong size;
     19 } Vector;
     20 
     21 Vector* Vec(Type);
     22 Type Vecadd_(Type*, ulong);
     23 void Vecclose_(Type*, ulong);
     24 void Vecdel_(Type*, ulong, ulong);
     25 void Vecinit_(Type*, ulong, void(*)(), void(*)());
     26 void Vecinsure_(Type*, ulong, ulong);
     27 ulong Vecsiz(Type);
     28 void Veczero_(Type*, ulong);