Re: cu coredumps

看板DFBSD_bugs作者時間21年前 (2004/10/28 03:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串14/19 (看更多)
(1) No you cannot safely use data that has been free()'d. Not ever. The original free() 15+ years ago had the side effect that the last free()'d data could still be used until the next free(), but nobody in their right mind programs to that spec any more. (2) No, you cannot assume that freed data will always cause a seg fault, or contain good or bad data. (3) Stop worrying about performance for operations that are executed once and will take far less then 1 microsecond, and stop worrying about memory leaks for one-time string operations. Don't worry about freeing the old data in this case. (4) Use asprintf(). Do not use malloc+str*() functions. Especially do not use str*() functions for this sort of thing. Just use asprintf(). -Matt
文章代碼(AID): #11V_1z00 (DFBSD_bugs)
文章代碼(AID): #11V_1z00 (DFBSD_bugs)