Re: 2 bytes allocated problems

2010-02-25 Thread Matthias Andree
Am 24.02.2010, 20:55 Uhr, schrieb Dag-Erling Smørgrav d...@des.no: Why is there a 0 after the 'i'? Because when you write abcdefghi, the compiler actually stores abcdefghi\0. That's the definition of string in C: a sequence of characters immediately followed by a 0. If you don't want the 0

Re: 2 bytes allocated problems

2010-02-25 Thread Dag-Erling Smørgrav
Matthias Andree matthias.and...@gmx.de writes: Dag-Erling Smørgrav d...@des.no writes: char a[9] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' }; char a[9] = abcdefghi; suffices. The compiler knows there isn't room for the terminal '\0' and omits it. Some compilers (gcc at least) warn

Re: 2 bytes allocated problems

2010-02-25 Thread Max Laier
On Thursday 25 February 2010 23:46:03 Dag-Erling Smørgrav wrote: Matthias Andree matthias.and...@gmx.de writes: Dag-Erling Smørgrav d...@des.no writes: char a[9] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' }; char a[9] = abcdefghi; suffices. The compiler knows there isn't room

2 bytes allocated problems

2010-02-24 Thread Andrey Zonov
Hi, When I try allocated pointer to a pointer, and in it some pointers (important: size is 2 bytes), the pointers lose their boundaries. Why it can happen? Test program in attach. PS in freebsd 7, it's ok, in Linux too. -- Andrey Zonov alloc.c Description: Binary data

Re: 2 bytes allocated problems

2010-02-24 Thread Max Laier
On Wednesday 24 February 2010 14:44:35 Andrey Zonov wrote: Hi, When I try allocated pointer to a pointer, and in it some pointers (important: size is 2 bytes), the pointers lose their boundaries. Why it can happen? Test program in attach. Your test program is broken: #define S1 ab

Re: 2 bytes allocated problems

2010-02-24 Thread Dag-Erling Smørgrav
Andrey Zonov andrey.zo...@gmail.com writes: When I try allocated pointer to a pointer, and in it some pointers (important: size is 2 bytes), the pointers lose their boundaries. Pointers have no boundareis in C. PS in freebsd 7, it's ok, in Linux too. Only by accident. DES -- Dag-Erling

Re: 2 bytes allocated problems

2010-02-24 Thread Andrey Zonov
And how free() finds that the need to release? Dag-Erling Smørgrav пишет: Andrey Zonov andrey.zo...@gmail.com writes: When I try allocated pointer to a pointer, and in it some pointers (important: size is 2 bytes), the pointers lose their boundaries. Pointers have no boundareis in C.

Re: 2 bytes allocated problems

2010-02-24 Thread Dag-Erling Smørgrav
Andrey Zonov andrey.zo...@gmail.com writes: Dag-Erling Smørgrav d...@des.no writes: Pointers have no boundareis in C. And how free() finds that the need to release? That is a very simple question with a very complicated answer. Whole books have been written about the subject. Normally, I'd