I am a little bit in hurry!
I wrote code for a stack and a double linked list which I need for a actual project. It would be nice if anyone could test it. I don't have the time now to test it as I should.
czerny
::: old bugs removed, new bugs created :-)
::: more of them
I see that there are 0 downloads. Was the last release sooo bad?
I have already downloaded it time ago.
I had no time to test it, but formally they seems ok.
If you have uploaded a new version the download counter resets, and if you don't add a new post the update is not signaled as new post.
Quote from: frankie on May 16, 2013, 10:18:53 AM
If you have uploaded a new version the download counter resets, and if you don't add a new post the update is not signaled as new post.
Ahhh! I didn't know that.
This is a new version with a circular buffer for strings (CRing). ;D
A wide char version (WRing) will follow.
I would like to have some more challanging test examples.
Any ideas?
A simple test case would be nice...
What is the difference between the Ring and the circular buffer?
You use CircBufWrite (but no CircBufRead), RingWrite and RingRead, each of them with a memcpy. In my implementation, there is something like CircBufferGetPointer, but the user has to decide how to write into the buffer. For example, GetCurrentDirectory(260, CircBufferGetPointer()). IMHO it avoids unnecessary copies...
Quote from: jj2007 on May 24, 2013, 12:35:52 AM
A simple test case would be nice...
Search for circbuf-tst.c
Quote from: jj2007 on May 24, 2013, 12:35:52 AM
In my implementation, there is something like CircBufferGetPointer, but the user has to decide how to write into the buffer. For example, GetCurrentDirectory(260, CircBufferGetPointer()). IMHO it avoids unnecessary copies...
GetCurrentDirectory(260, CircBufWrite(Buffer, NULL, 260))
Quote from: czerny on May 24, 2013, 12:48:45 AM
GetCurrentDirectory(260, CircBufWrite(Buffer, NULL, 260))
void *p = &R->buffer[R->pos];
if (data)
memcpy(p, data, len);
else
memset(p, 0, len);OK, I see.
Quote from: jj2007 on May 24, 2013, 12:35:52 AM
What is the difference between the Ring and the circular buffer?
Ring is a data structure which holds
equal sized objects. They are written by a producer and read by a consumer who
remove the objects. It is possible to detect, if the ring is full or empty. CircBuf is more a all purpose temporary memory, as discussed.
It would be interesting for me to discuss such a ring in a multithreaded environment with different threads, producing/consuming objects.
Per example: What is the overhead of using the C11 _Atomic qualifier.