Commit ca196c35 authored by colinw's avatar colinw

Added an oggz_realloc #define and fixed a bug that would result in bad ptrs

if and when a call to oggz_realloc() failed



git-svn-id: http://svn.annodex.net/liboggz/trunk@446 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 7a7759f6
......@@ -213,10 +213,11 @@ oggz_vector_grow (OggzVector * vector)
}
new_elements =
realloc (vector->data, (size_t)new_max_elements * sizeof (oggz_data_t));
oggz_realloc (vector->data, (size_t)new_max_elements * sizeof (oggz_data_t));
if (new_elements == NULL) {
vector->nr_elements--;
vector->data = NULL;
return NULL;
}
......@@ -306,12 +307,15 @@ oggz_vector_remove_nth (OggzVector * vector, int n)
new_max_elements = vector->max_elements/2;
new_elements =
realloc (vector->data,
(size_t)new_max_elements * sizeof (oggz_data_t));
if (new_elements == NULL)
return NULL;
oggz_realloc (vector->data,
(size_t)new_max_elements * sizeof (oggz_data_t));
if (new_elements == NULL)
{
vector->data = NULL;
return NULL;
}
vector->max_elements = new_max_elements;
vector->data = new_elements;
}
......@@ -382,12 +386,12 @@ oggz_vector_pop (OggzVector * vector)
new_max_elements = vector->max_elements/2;
new_elements =
realloc (vector->data,
(size_t)new_max_elements * sizeof (oggz_data_t));
oggz_realloc (vector->data,
(size_t)new_max_elements * sizeof (oggz_data_t));
if (new_elements != NULL) {
vector->max_elements = new_max_elements;
vector->data = new_elements;
vector->max_elements = new_max_elements;
vector->data = new_elements;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment