Why move the check before the call to malloc? Not only would it waste time to malloc a bunch of space we don't use, but also we'd need to remember to free it so we don't leak memory. Char * strReplace(const char *src, const char *old, const char *new)ĭst = malloc(sizeof(char) * (dstLen + 1)) // +1 for NUL terminator
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |