Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junjizhi/fifo
A first-in-first-out(FIFO) queue implemented in C, based on the linux kernel linked list
https://github.com/junjizhi/fifo
Last synced: 12 days ago
JSON representation
A first-in-first-out(FIFO) queue implemented in C, based on the linux kernel linked list
- Host: GitHub
- URL: https://github.com/junjizhi/fifo
- Owner: junjizhi
- License: gpl-2.0
- Created: 2015-03-05T05:41:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-03-05T08:40:05.000Z (over 9 years ago)
- Last Synced: 2024-07-11T12:22:23.092Z (4 months ago)
- Language: C
- Size: 148 KB
- Stars: 7
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fifo
A first-in-first-out(FIFO) queue implemented in C, based on the linux kernel linked list. It is a practice of how to use list_head data structure, etc.## Usage
#define QueueElement TYPEQueue* q = initQueue(20);
QueueElement e1,e2;
/* init e1, e2*/
enqueue(q,e1);
enqueue(q,e2);
dequeue(q);
# Type generic issue
This queue implementation is type generic using void* type. It needs to be downcast to a certain
data type, which can be dangerous without proper type runtime check.Alternatively, we can use Macro + structure offset to implement type generic queue data structures. Examples
include:
- list.h (kernel linked list),
- [uthash](http://troydhanson.github.io/uthash/) approach.
However, the usage is a bit complicated because
- it has certain assumptions about how to use the data structure, e.g., list_for_each_entry(tmp, &frame_queue->list, list). tmp needs to be the struct type contains the list member declaration.
- it needs to use the API calls to manipulate the data struct. That is, you need to memorize a bunch of functions, e.g., list_for_each_entry, HASH_FIND_INT(), etc.## Credits
list.h is copied from Kulesh Shanmugasundaram's site:
http://isis.poly.edu/kulesh/stuff/src/klist/
Kulesh deserves all the credits for posting the explanation and
the adapted source code.