char* CuStrCopy(const char* old) { int len = strlen(old); char* newStr = CuStrAlloc(len + 1); strcpy(newStr, old); return newStr; }
char* CuStrCopy(const char* old) { int len = (int)strlen(old); char* newStr = CuStrAlloc(len + 1); if (newStr != NULL) strcpy(newStr, old); else fprintf(stderr, "%s: malloc in CuStrCopy.\n", CU_FAIL_HEADER); return newStr; }
void TestCuStringAppendFormat(CuTest* tc) { int i; char* text = CuStrAlloc(301); /* long string */ CuString* str = CuStringNew(); for (i = 0 ; i < 300 ; ++i) text[i] = 'a'; text[300] = '\0'; CuStringAppendFormat(str, "%s", text); /* buffer limit raised to HUGE_STRING_LEN so no overflow */ CuAssert(tc, "length of str->buffer is 300", 300 == strlen(str->buffer)); }