Thread: malloc?
View Single Post
  #6   Spotlight this post!  
Unread 21-06-2007, 21:24
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: malloc?

I believe what you're looking for is a buffer. You statically allocate a char array, and have an index showing the next place to write a character.

Also, if you want to get fancy, you can loop the buffer around--a ring buffer. So when you reach the end of the buffer, you start at the beginning. This is very eficiently done when your buffer size is a power of two. (index &= 0x1FF)

Just some thoughts.