Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
Diff: libs/Network/uip/fifo.cpp
- Revision:
- 2:1df0b61d3b5a
diff -r ab59fc9af055 -r 1df0b61d3b5a libs/Network/uip/fifo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/Network/uip/fifo.cpp Fri Feb 28 18:52:52 2014 -0800 @@ -0,0 +1,39 @@ +// c accessibllity to the c++ fifo class +#include "fifo.h" +#include "c-fifo.h" + +void *new_fifo() +{ + return new Fifo<char*>; +} + +void delete_fifo(void *fifo) +{ + if(fifo == NULL) return; + Fifo<char *> *f= static_cast<Fifo<char *> *>(fifo); + while(f->size() > 0) { + char *s= f->pop(); + if (s != NULL) { + free(s); + } + } + delete f; +} + +char *fifo_pop(void *fifo) +{ + Fifo<char *> *f= static_cast<Fifo<char *> *>(fifo); + return f->pop(); +} + +void fifo_push(void *fifo, char *str) +{ + Fifo<char *> *f= static_cast<Fifo<char *> *>(fifo); + f->push(str); +} + +int fifo_size(void *fifo) +{ + Fifo<char *> *f= static_cast<Fifo<char *> *>(fifo); + return f->size(); +}