Char* to double, int, and back

Luminary
Posts: 5,143
Joined: 2002.04
Post: #16
It is *not* safe to delete something you've malloc()ed, nor to free() something you've new'd. Don't do it.

Also, remember to delete[] stuff you new[]!
Quote this message in a reply
Hog
Member
Posts: 151
Joined: 2002.09
Post: #17
the stl vector is not that inefficient in reallocation as tries to work around the problem by allocating extra space for the vector.
if that's still too inefficient for you you could go with a list which however brings up issues concerning accessibility, but that pretty much depends on your requirements.
Quote this message in a reply
Moderator
Posts: 373
Joined: 2006.08
Post: #18
wait...did I use delete [] wrong in my example code? I thought that code would delete all of the memory new [] 'ed?
Thanks for the advice everyone Smile
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #19
If you didn't use realloc it would be correct. Of course, using realloc with new[] (or even just new, along with using free with either of the news) isn't guaranteed to work.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  converting text input to a c char NelsonMandella 6 4,209 Feb 4, 2010 10:58 AM
Last Post: NelsonMandella
  Java: Double Buffering xDexx 11 8,821 Jan 27, 2009 03:48 AM
Last Post: paven
  (unsigned) char, bitsets when using - + / * wyrmmage 7 4,876 Jul 21, 2007 04:01 PM
Last Post: wyrmmage
  Return char if input is char, else - int? Achithyn 2 3,043 Aug 6, 2006 03:43 AM
Last Post: backslash
  ProGraph back from the dead? Leisure Suit Lurie 0 2,070 Dec 7, 2005 03:38 PM
Last Post: Leisure Suit Lurie