Your call to realloc is fine (aside from not handling the NULL case), in terms of how realloc is used. My best guess from your wording is that you're doing something like this...

Code:
temp = calloc(30, sizeof(char));

strncpy(temp, SomeSortOfInput, 30);

//Since the input string is probably less than 30 characters, lets get rid of what we don't need...
int i;
for(i = 0; temp[i] != 0; ++i);

// The for loop stopped at the '\0' terminator, so i is the size of the string...
temp = realloc(temp, i * sizeof(char));
There's several problems you may be running into if you're doing something like the above. Firstly, if you used strcpy instead of strncpy, you could easily run past the end of temp in multiple places. But the problem I think you're probably having is that after the for loop, i doesn't contain the size of the string. It contains the location of the null terminator. Therefore, when you call realloc, it realloc's only up to the null terminator, but not including it, so when you work with the string later on, you're running way off into nowhere. The call to realloc, in this case, needs to be

Code:
temp = realloc(temp, (i + 1) * sizeof(char));
But depending on what your checking conditions are in the for loop, you may or may not need the +1, or you may need something else entirely.