forked from Archive/PX4-Autopilot
format src/systemcmds/reflect
This commit is contained in:
parent
01cc966b3b
commit
bed3fdf952
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue