plan9port

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

Vecdel.c (384B)


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