Use realloc to allocate memory used to save class names

Use realloc() as a allocator instead of malloc() because, apparently, libcss uses realloc(). 
So this patch would make them in sync.