[asterisk-dev] Update coding guidelines
Kevin P. Fleming
kpfleming at digium.com
Sat Dec 30 08:47:29 MST 2006
Matthew Fredrickson wrote:
> Why? Not to "over analyze" the examples, but array initialization
> instead of pointer initialization is most important when you might go
> back and modify the array. If it's not going to be modified, as in this
> example, then there should be no problem with leaving name as it is. I
> agree, that not putting const there might make it a bit less literal and
> if that string were to be modified in that code it might cause problems
> in some architectures/compilers, in this case it would not since it does
> not modify the pointed to string.
And in fact in this case, since it known that the string will not be
modified, using this form of initialization actually improves the memory
usage of the application, because the string will live in read-only
(code segment, etc.) memory, instead of writable (data segment) memory.
When the program forks, the pages containing the code/constant
strings/etc. are not duplicated, because they are not writable.
More information about the asterisk-dev
mailing list