Pelles C forum

C language => Work in progress => Topic started by: czerny on February 06, 2013, 06:32:25 PM

Title: lifofifo
Post by: czerny on February 06, 2013, 06:32:25 PM
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

Title: Re: lifofifo
Post by: czerny on May 16, 2013, 09:44:05 AM
I see that there are 0 downloads. Was the last release sooo bad?
Title: Re: lifofifo
Post by: frankie on May 16, 2013, 10:18:53 AM
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.
Title: Re: lifofifo
Post by: czerny on May 16, 2013, 07:20:37 PM
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.
Title: Re: lifofifo
Post by: czerny on May 21, 2013, 11:41:34 PM
This is a new version with a circular buffer for strings (CRing). ;D
A wide char version (WRing) will follow.
Title: Re: lifofifo
Post by: czerny on May 22, 2013, 08:30:45 AM
I would like to have some more challanging test examples.
Any ideas?
Title: Re: lifofifo
Post by: jj2007 on May 24, 2013, 12:35:52 AM
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...
Title: Re: lifofifo
Post by: czerny on May 24, 2013, 12:48:45 AM
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))
Title: Re: lifofifo
Post by: jj2007 on May 24, 2013, 11:19:07 AM
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.
Title: Re: lifofifo
Post by: czerny on May 24, 2013, 03:24:51 PM
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.
Title: Re: lifofifo
Post by: czerny on May 24, 2013, 03:37:37 PM
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.