I was reading and saw that it was the implementation of ltrim (left trim)
Char * Ltrim (char * str) {char * ptr; Int len; For (ptr = str; * ptr & release ((int) * ptr); ++ ptr); Lane = Stellen (PTR); Memmove (str, ptr, len + 1); Return str; } If I leave memmove and return ptr isntead, then what are the bad things?
char * ltrim (char * str) {char * ptr; Int len; For (ptr = str; * ptr & release ((int) * ptr); ++ ptr); Return PTR; }
If you come back to ptr - that is, Pointer value in addition to the original pointer - and if that pointer is the only indicator in the original memory block, then no one will be able to open , and the memory leak will occur. You can call between allocated blocks on a pointer, but at the beginning of the block, on only one indicator - that is, only basically molok () . For some reasons, you can be sure that an indicator will be preserved in the original block, or the block will never be required to free, then Memmove () is required is not; But these are poor assumptions for general purpose utility regulation.
Comments
Post a Comment