How to check if a structure is initialized?

arrays, c, data-structures, initialization

Solution

You can't. To fix the problem, always initialize the struct before using it (even if all the initialization does is set the struct to a known "blank"/"not populated" state).

Problem

I have a table that I'm implementing with data structures. An important block of my code looks like this(h is a data structure, table is a table that stores other structures): ``` (h->table[hash(key, h->size)] ``` While my code is running, some table[i]'s will be initialized, and some aren't. Whenever I test my code on a table[i] that hasn't been initialized yet, I get a valgrind error which basically says I can't work with an uninitialized array. My question is, how would I check to see if a certain h->table[i] is initialized or not?

Original source