Question on Pointer Arithmetic
Posted
by pws5068
on Stack Overflow
See other posts from Stack Overflow
or by pws5068
Published on 2010-03-31T21:26:32Z
Indexed on
2010/03/31
21:33 UTC
Read the original article
Hit count: 491
Heyy Everybody! I am trying to create a memory management system, so that a user can call myMalloc, a method I created. I have a linked list keeping track of my free memory. My problem is when I am attempting to find the end of a free bit in my linked list. I am attempting to add the size of the memory free in that section (which is in the linked list) to the pointer to the front of the free space, like this.
void *tailEnd = previousPlace->head_ptr + ((previousPlace->size+1)*(sizeof(int));
I was hoping that this would give me a pointer to the end of that segment. However, I keep getting the warning:
"pointer of type 'void*' used in arithmetic"
Is there a better way of doing this? Thanks!
© Stack Overflow or respective owner