format src/systemcmds/reflect

This commit is contained in:
Daniel Agar 2015-09-05 12:21:12 -04:00
parent 01cc966b3b
commit bed3fdf952
1 changed files with 45 additions and 36 deletions

View File

@ -64,14 +64,18 @@ static void allocate_blocks(void)
{
while (nblocks < MAX_BLOCKS) {
blocks[nblocks] = calloc(1, sizeof(struct block));
if (blocks[nblocks] == NULL) {
break;
}
for (uint32_t i = 0; i < sizeof(blocks[nblocks]->v) / sizeof(uint32_t); i++) {
blocks[nblocks]->v[i] = VALUE(i);
}
nblocks++;
}
printf("Allocated %u blocks\n", nblocks);
}
@ -95,17 +99,22 @@ reflect_main(int argc, char *argv[])
while (true) {
char buf[128];
ssize_t n = read(0, buf, sizeof(buf));
if (n < 0) {
break;
}
if (n > 0) {
write(1, buf, n);
}
total += n;
if (total > 1024000) {
check_blocks();
total = 0;
}
}
return OK;
}