Re: cu coredumps

看板DFBSD_bugs作者時間21年前 (2004/10/28 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串11/19 (看更多)
On Wed, Oct 27, 2004 at 12:51:51PM -0400, Timour Ezeev wrote: > 2. If you dont want to create a new pointer, swap pointers in plase, > like this > > (int)tmp_cp ^= (int)cp; (int)cp ^= (int)tmp_cp; (int)tmp_cp ^= > (int)cp; > free(tmp_cp); > > or something similar :) No, please don't. This is (a) obscure and hard to read (b) uses a depricated extension of GCC (lhs cast) (c) depends on sizeof(int) == sizeof(void *) (d) slower than the version with a local variable If you don't want to add a variable for the whole function scope, do a { void *local_tmp = cp; cp = tmp_cp; tmp= cp; } which is both easier to read and faster. Joerg
文章代碼(AID): #11V-A200 (DFBSD_bugs)
文章代碼(AID): #11V-A200 (DFBSD_bugs)