RE: [Haifux] c with a spoon and pointer arithmetic.

2005-03-10 Thread Joseph Halloun
Dear Tzahi, I think that's the problem is that you can't delete members from an array -- even if it was created dynamically, because the memory allocation here is allocated continuously as an ordinary static array -- (the created dynamic memory you issued is an array for every thing). You can

Re: [Haifux] Re: c with a spoon and pointer arithmetic

2005-03-10 Thread Yoni
On the same subject, can someone please explain a bit about the free() function ? what does it do, and how come you can only send it the memory address which you started allocating from ? (I missed the last lecture because i had to study to some test :-( ) Yoni. - Original Message -

[Haifux] Re: c with a spoon and pointer arithmetic

2005-03-10 Thread Shlomi Fish
On Thursday 10 March 2005 14:20, Yoni wrote: On the same subject, can someone please explain a bit about the free() function ? what does it do, and how come you can only send it the memory address which you started allocating from ? In ANSI C, you allocate a region of dynamically allocated

Re: [Haifux] Re: c with a spoon and pointer arithmetic

2005-03-10 Thread Orr Dunkelman
Standing on one foot (please translate to Hebrew): When you ask for 16 bytes you actually get 20 (at least) When you do ptr = malloc(16) (size of allocated area) | Start of allocated area unsigned int (or ...)| allocated area of 16 bytes ^

Re: [Haifux] Re: c with a spoon and pointer arithmetic

2005-03-10 Thread guy keren
On Thu, 10 Mar 2005, Yoni wrote: Thanks for the answers :-) If i understand correctly, the free function might look something like this: void free(pointer) { // gets start address, and size of memory to free to the os letGoOfMemory(pointer-1,*(pointer-1)); } do i understand correctly?

[Haifux] Re: c with a spoon and pointer arithmetic

2005-03-10 Thread Shlomi Fish
On Thursday 10 March 2005 16:17, Diego Iastrubni wrote: Shlomi Fish wrote: mem[102] = 'c'. SEGFAULT! the allocated memory is found at memory 100-103. Bad Thazi! No, it's OK so far. how come? he is refering to memory which is not allocated? lets ignore the issue that the amount of