1 /* Filter driver - utility functions */
7 static clock_t next_alarm
;
9 /*===========================================================================*
11 *===========================================================================*/
12 char *flt_malloc(size_t size
, char *sbuf
, size_t ssize
)
14 /* Allocate a buffer for 'size' bytes. If 'size' is equal to or less
15 * than 'ssize', return the static buffer 'sbuf', otherwise, use
16 * malloc() to allocate memory dynamically.
23 if(!(p
= alloc_contig(size
, 0, NULL
)))
24 panic("out of memory: %d", size
);
29 /*===========================================================================*
31 *===========================================================================*/
32 void flt_free(char *buf
, size_t size
, const char *sbuf
)
34 /* Free a buffer previously allocated with flt_malloc().
38 free_contig(buf
, size
);
41 /*===========================================================================*
43 *===========================================================================*/
44 clock_t flt_alarm(clock_t dt
)
51 r
= sys_setalarm(dt
, 0);
54 panic("sys_setalarm failed: %d", r
);
58 panic("clearing unset alarm: %d", r
);
62 panic("overwriting alarm: %d", r
);
63 if ((r
= getuptime(&next_alarm
)) != OK
)
64 panic("getuptime failed: %d", r
);