ref: 56bd332994102b4e194819abb5e087a8895452f9
dir: /tests/testextents.c/
#include <u.h> #include <libc.h> #include "../dat.h" #include "../extents.h" #include <bio.h> /* test the extents functionality { echo 2 3 ; echo 100 3; } | ./6.testextents */ int chatty9p = 0; static void usage(void) { fprint(2, "usage: testextents [-D ]\n"); exits("usage"); } void main(int argc, char *argv[]) { Extents es; s8 *line, *p; Biobuf *bp; u64 bno, len; ARGBEGIN{ default: usage(); case 'D': chatty9p=8; break; }ARGEND if(argc != 0) usage(); bp = Bfdopen(0, OREAD); Blethal(bp, nil); initextents(&es); while((line = Brdstr(bp, '\n', 1)) != nil) { bno = strtoull(line, &p, 10); p++; /* for the space */ len = strtoull(p, nil, 10); bfree(&es, bno, len); free(line); } showextents(1, "", &es); /* why bother? just exits(nil) as cinap suggests */ Bterm(bp); exits(nil); }