stew

a monorepo of some sort
git clone git://git.nsmpr.xyz/stew.git
Log | Files | Refs

util.h (736B)


      1 // #pragma lib "libutil.a$O"
      2 
      3 typedef struct Type Type;
      4 
      5 struct Type {
      6 	usize nbytes;
      7 };
      8 
      9 extern Type CharType;
     10 
     11 typedef struct Array Array;
     12 
     13 struct Array {
     14 	Type *type;
     15 	int count;
     16 	void p[1];
     17 };
     18 
     19 typedef struct Slice Slice;
     20 
     21 struct Slice {
     22 	Array *arr;
     23 	void *p;
     24 	int len, cap;
     25 };
     26 
     27 Array * allocarray(Type *, int);
     28 void freearray(Array *);
     29 
     30 Slice * allocslice(Type *, int, int);
     31 Slice * sliceappendp(Slice *, int, void *);
     32 Slice * sliceappend(Slice *, int count, ...);
     33 Slice * slicecopy(Slice *);
     34 Slice * slicejoin(Slice *, Slice *);
     35 void *slicegetp(Slice *, int);
     36 void freeslice(Slice *);
     37 
     38 long voidlen(void **); /* strlen, but for array of pointers */
     39 char ** strfind(char **, long n, char *); /* find string in array of strings */