Change the size of a mpg123_string
- Returns:
- 0 on error, 1 on success
Definition at line 35 of file stringbuf.c.
Referenced by convert_latin1(), convert_utf16bom(), convert_utf8(), mpg123_copy_string(), mpg123_grow_string(), and store_id3_text().
{
debug3("resizing string pointer %p from %lu to %lu", (void*) sb->p, (unsigned long)sb->size, (unsigned long)new);
if(new == 0)
{
if(sb->size && sb->p != NULL) free(sb->p);
mpg123_init_string(sb);
return 1;
}
if(sb->size != new)
{
char* t;
debug("really!");
t = (char*) safe_realloc(sb->p, new*sizeof(char));
debug1("safe_realloc returned %p", (void*) t);
if(t != NULL)
{
sb->p = t;
sb->size = new;
return 1;
}
else return 0;
}
else return 1;
}