![]() ![]() Otherwise dequeue is certainly using the line. ![]() If the line is not full, one past the last element will contain NULL to indicateĥ - If enqueue finishes filling a line, it will check if the next is empty. Will be sent back by dequeue, so it can store a pointer to anything andĪlso work with other data types of size up to sizeof(void *).ġ - When it's created, lines of fixed sizes are allocatedĢ - Dequeue is set to the first position, enqueue to the secondģ - Both just walk along the list and never share a LineĤ - If dequeue moves to the same line as enqueue, enqueue will go to the next. The queue stores only elements of sizeof(void *), whatever is received by enqueue The list to find that node in order to update the pointer to the next The one they are operating on as an argument so they don't have to walk through And that's ok because most functions take the line that comes before They won't have to deal with special cases. Is there because I thought it would make the the other functions simpler since The queue structure just stores meta info and points to lines. Also the end of the line, if it's not full, can be delimited by So, when I do position++ it will move sizeof(void *) and point to the next I'm using double pointers because I expect it to act like an array of void *. It contains a link to the next and can hold void *. Int qu_enqueue(Queue *queue, void *content) Queue *qu_allocate_custom(size_t lines, size_t capacity) New lines are added only when all lines are full, not counting the dequeue line. All lines have fixed sizes and dequeue/enqueue never share a line. Please review my code and let me know if there are any errors and how to improve code quality and performance. I was reading about opaque pointers and decided to try it with queues. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |