Skip to content

Instantly share code, notes, and snippets.

@imakin
Created May 9, 2016 03:17
Show Gist options
  • Save imakin/3ad108305faca7fc60c4033f20052b0d to your computer and use it in GitHub Desktop.
Save imakin/3ad108305faca7fc60c4033f20052b0d to your computer and use it in GitHub Desktop.
/**
* makin 2016
*/
#include <stdint.h>
#include <stdio.h>
#define MAP_POS_X 0
#define MAP_POS_Y 1
#define MAP_NEXT_NUM 2
#define MAP_EXPLORED 3
typedef struct linkedlist_st linkedlist;
struct linkedlist_st {
long *data_long;
linkedlist *next;
linkedlist **multinext;
linkedlist *prev;
};
#define new_map(obj) \
malloc(sizeof(linkedlist)); \
obj->data_long = malloc(3*sizeof(long));
int main(int argc, char* argv[])
{
linkedlist *map, *node;
node = malloc(sizeof(linkedlist));
map = new_map(map);
map->data_long[MAP_POS_X] = 1;
map->data_long[MAP_POS_Y] = 2;
map->data_long[MAP_NEXT_NUM] = 3;
map->multinext = malloc(3*sizeof(linkedlist*));
map->multinext[0] = new_map(map->multinext[0]);
map->multinext[1] = new_map(map->multinext[1]);
map->multinext[2] = new_map(map->multinext[2]);
map->multinext[1]->data_long[MAP_POS_X] = 10;
map->multinext[1]->data_long[MAP_POS_Y] = 20;
printf("(%d,%d)\n",map->multinext[1]->data_long[MAP_POS_X], map->multinext[1]->data_long[MAP_POS_Y]);
long test;
test = 0xFFFFFFFF;
printf("%d\n", test);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment