pointers and memory references (Re: Confusion about build cycle and vmlinux/bzImage (need uncompressed ELF image of built kernel))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I did a few simple independent tests between 'char *foo = "foo"' and 'char 
> foo[] = "foo"' and they confirmed what the KJ docs say, that the latter 
> results in a smaller object. So I did a test with <fs/partitions/check.c>.

I don't know what kind of documentation you've read, but

> static char *make_block_name(struct gendisk *disk)
> {
> -	static char *block_str = "block:";

this is the declaration of the variable in the RAM holding address, i.e.
pointer;

> +	static char block_str[] = "block:";

this is the declaration of the memory reference, i.e. address, number,
constant.

In case of "*const" _optimizing_ compiler *may* not use memory to store
the value of the address.

So this is not kind of "some doc say", it's pretty much about
understanding semantics of the C.
____


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux