casting char* to char**

Posted by blue_whale on Stack Overflow See other posts from Stack Overflow or by blue_whale
Published on 2012-10-17T04:59:42Z Indexed on 2012/10/17 5:00 UTC
Read the original article Hit count: 129

Filed under:
|

I am having a tough time understanding the following piece of code:

int stride = 512;
int max_len = 1024 * stride; 
char *addr = (char *)malloc(max_len);
for (int i=stride; i<max_len; i += stride)
    *(char **)&addr[i-stride] = (char*)&addr[i];
*(char **)&addr[i-stride] = (char*)&addr[0];

Looking at the code it seems this is trying to create some kind of circular link list. But I have no clue what those casts are actually doing.

© Stack Overflow or respective owner

Related posts about c

    Related posts about casting