Char* to double, int, and back

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
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
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

Worlds at War (Current Project) -
Quote this message in a reply
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 7,007 Feb 4, 2010 10:58 AM
Last Post: NelsonMandella
  Java: Double Buffering xDexx 11 13,329 Jan 27, 2009 03:48 AM
Last Post: paven
  (unsigned) char, bitsets when using - + / * wyrmmage 7 7,831 Jul 21, 2007 04:01 PM
Last Post: wyrmmage
  Return char if input is char, else - int? Achithyn 2 4,559 Aug 6, 2006 03:43 AM
Last Post: backslash
  ProGraph back from the dead? Leisure Suit Lurie 0 2,993 Dec 7, 2005 03:38 PM
Last Post: Leisure Suit Lurie