I have the following struct
struct vertice_t{
char city;
char connectedBy;
unsigned short airportCost;
unsigned short primKey;
int queueIndex;
struct adjacency_list_t * adjacencyList;
};
struct adjacency_list_t{
struct adjacency_list_node_t * first;
struct adjacency_list_node_t * last;
};
struct adjacency_list_node_t{
unsigned short weight;
struct vertice_t * vertice;
struct adjacency_list_node_t * next;
};
When I do sizeof(struct vertice_t) I get the value 24. But I can see by myself that this struct only takes 1 + 1 + 2 + 2 + 4 + 8 = 18Bytes
Why does this happen? Is there anyway I could compress the data in the struct above to make it smaller? This is for a project and I need to reduce the whole memory usage by 30%.
Thanks!