Re: far pointers
"Arthur J. O'Dwyer" wrote:[color=blue]
>[/color]
.... snip ...[color=blue]
>
> However, unsigned types are guaranteed to have pure binary
> representations , which means that memsetting an 'unsigned int' to
> zero /will/ set its value to the unsigned integer zero! Ditto
> 'unsigned char', 'unsigned long', et cetera. (And I think ditto
> the new C99 fixed-width types: 'int32_t' and 'int_least8_t' and
> friends.)
>
> I often use 'calloc' in image processing; for example, to get
> a grayscale image of size w*h initialized to black, I'll write
>
> unsigned char *im = calloc(w*h, 1);
>
> So 'calloc' does have its uses; they're just rare.[/color]
I believe there is a movement for an addendum to C99 to insist on
that all bytes zero representation of integer zeroes. AFAIK there
are no installations extant where it doesn't work.
The real trap is using it to initialize a pointer array to NULLs.
Also floating point.
--
Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
"Arthur J. O'Dwyer" wrote:[color=blue]
>[/color]
.... snip ...[color=blue]
>
> However, unsigned types are guaranteed to have pure binary
> representations , which means that memsetting an 'unsigned int' to
> zero /will/ set its value to the unsigned integer zero! Ditto
> 'unsigned char', 'unsigned long', et cetera. (And I think ditto
> the new C99 fixed-width types: 'int32_t' and 'int_least8_t' and
> friends.)
>
> I often use 'calloc' in image processing; for example, to get
> a grayscale image of size w*h initialized to black, I'll write
>
> unsigned char *im = calloc(w*h, 1);
>
> So 'calloc' does have its uses; they're just rare.[/color]
I believe there is a movement for an addendum to C99 to insist on
that all bytes zero representation of integer zeroes. AFAIK there
are no installations extant where it doesn't work.
The real trap is using it to initialize a pointer array to NULLs.
Also floating point.
--
Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Comment