The difference here I think is not between 0 & NULL but between an integer & a pointer. On a 64 bit system while int is still 4 bytes, the pointer could be (because I had read somewhere that some 64 bit archs use 32 bit pointers in some cases) 8 bytes. I think you should be comparing between - int *p = NULL & int *p = 0 rather than with, int p = 0 regards, Kishore A K -- "Dream as if you'll live forever; Live as if you'll die today." On Thu, 18 Nov 2004 14:35:22 +0530, Vishal Soni <vishal@xxxxxxxxxxxxxx> wrote: > > > I remember a big discussion happening on LKML on this > > topic (i.e., NULL vs 0) a couple of months back. It must > > be still available in their mail archives. Try googling for > > "Use NULL instead of integer 0" & you must find it. Must > > say it was a pretty heated discussion. Dont know what > > the outcome was. I stopped following it after sometime. > Tried some thing and pasting a copy here...which tells clearly abt NULL > pointer and using zero(integer) > C code -- used > file name : null.c > int main() > { > int *p= NULL; > return 0; > } > > file name : zero.c > int main() > { > int p = 0; > return 0; > } > > Assembly snippet on 64 bit machine for null.c > main: > .LFB3: > pushq %rbp > .LCFI0: > movq %rsp, %rbp > .LCFI1: > movq $0, -8(%rbp) <------------ > movl $0, %eax > leave > ret > > Assembly snippet on 64 bit machine for zero.c > main: > .LFB3: > pushq %rbp > .LCFI0: > movq %rsp, %rbp > .LCFI1: > movl $0, -4(%rbp) <------------- > movl $0, %eax > leave > ret > Check out the 7th line..... of both the snippets > If we see here 8 bytes are deducted from base pointer(in 64 bit machine -- > when variable p was NULL pointer) > and 4 bytes are deducted from rbp when p was integer....(obvious... Right > !!!!) > and thus the code differs....... > > Whereas in 32 bit machine, assembly snippets for null.c and zero.c are > similar. > main: > pushl %ebp > movl %esp, %ebp > subl $8, %esp > andl $-16, %esp > movl $0, %eax > addl $15, %eax > addl $15, %eax > shrl $4, %eax > sall $4, %eax > subl %eax, %esp > movl $0, -4(%ebp) > movl $0, %eax > leave > ret > > Interesting conclusions and concept to imbibe :) > Regards, > Vishal. > > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/