plan9port

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

Vecdel.c (411B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include <vec.h>
      4 
      5 extern Vector* Vec(Type);
      6 
      7 void
      8 Vecdel_(Type *p, ulong ms, ulong n)
      9 {
     10 	Vector *v;
     11 	char *q;
     12 
     13 	if (!p)
     14 		sysfatal("Vecdel: nil pointer");
     15 	v = Vec(*p);
     16 	if (!v->n)
     17 		return;
     18 	if (n >= v->n)
     19 		sysfatal("Vecdel: out of bounds");
     20 	q = (char*)*p + n * ms;
     21 	if (v->close)
     22 		v->close(q);
     23 	memmove(q, q + ms, (--v->n - n) * ms);
     24 	memset(q + (v->n - n) * ms, 0, ms);
     25 }