Making an array whose elements are defined by a struct This might be a basic question for C. I'm making a struct called check_t and I want to make an array whose elements are of type check_t. This array is called enqueued. The struct check_t contains an integer x and a lock (for multi-threading).

typedef struct _check_t{
  int x;
  pthread_mutex_t lock;
} check_t;

void *check_init(check_t *c)
  c-&gt;x = 0;
  pthread_mutex_init(&amp;c-&gt;lock,NULL);
}

check_t **enqueued;
for(i=0;i&lt;w*h;i++){
  enqueued[i] = (check_t *)malloc(sizeof(check_t));
  check_init(&amp;enqueued[i]);
} 


Mostly, I'm wondering if this is the correct way to make/allocate space for an array of check_ts.
1D array:

check_t *enqueued = malloc(N * sizeof(*enqueued));
enqueued[0].x = 5;
enqueued[N - 1].x = 2;


2D array:

check_t **enqueued = malloc(N * sizeof(*enqueued));
for(int i = 0; i &lt; N; i++)
    enqueued[i] = malloc(M * sizeof(**enqueued));
enqueued[0][0].x = 5;
enqueued[N - 1][M - 1].x = 2;