Thread: C realloc help
View Single Post
  #5   (View Single Post)  
Old 1st September 2008
Silverleaf Silverleaf is offline
Real Name: Luke Maurits
New User
 
Join Date: Aug 2008
Location: Adelaide, Australia
Posts: 2
Thumbs up

Quote:
Originally Posted by ephemera View Post
new_pointer = realloc(pointer, (pointer_size+100) * sizeof(int));
Duh, what a stupid mistake. Thanks ephemera! This has, of course, fixed things perfectly and valgrind now reports zero errors. I think I'll make a habit of avoiding calloc in favour of malloc in future on account of this, so that always using sizeof becomes a habit.
Reply With Quote