Wszelkie lepsze sugestie dotyczące funkcji c copyString, concatString


Poproszono mnie o wykonanie 2 funkcji copyString i concatString i zrobiłem to i zaimplementowałem je oba, ale na wyjściu, które otrzymałem, powiedziano mi, że można to zrobić lepiej, ale nigdy nie wyjaśniono, jak.
teraz zabija mnie, co mógłbym zrobić lepiej, a oto kod i chętnie usłyszę wszelkie sugestie.

void copyString (char **strDst, const char *strSrc)
{
     char *strTmp = NULL;
     int length = strlen (src);
     if (*strDst== NULL) 
     {
        *strDst= malloc (length);   
     }
     else 
     {  
         if (strlen(*strDst) != length)
         {
             strTmp = *strDst;
         }
         *strDst= malloc (length);  
     }
     strcpy (*strDst, strSrc);  
     if (strTmp != NULL)    
         free (strTmp );    
 }

void concatString (char **strDst, const char *cat)
{
     int cat_length = strlen (cat);
     if (cat_length > 0) 
     {  
         *strDst= realloc (*strDst, strlen (*strDst) + cat_length); 
          strcat (*strDst, cat);
     }
}




void main(int argc, char *argv[])
{
    char *str = NULL;
    copyString(&str, "Hello World");
    puts(str);
    copyString(&str,str+6);
    puts(str);
    concatString(&str, " Pesron");
}

Wynik powinien być następujący:
1. Cześć świat
2. Świat
3. Osoba ze świata

Dzięki.

questionAnswers(2)

yourAnswerToTheQuestion