I am trying to create a three dimensional struct array using malloc in c on MSVC. It compiles without error but when i debug it it gives an error after initializing some elements.
declaration:
typedef struct table_info
{
    unsigned long size;
    char code[33];
    char path[300];
}table_info;
table is a global variable and is defined as:
struct table_info ***table=NULL;
malloc and initialize table:
char garb[33] = { '\0' };
char garb_path[300] = { '\0' };
table = (table_info***)malloc(ROWS* sizeof(**table));
for (int m = 0; m < ROWS; m++)
{
    table[m] = (table_info**)malloc(COLS* sizeof(*table[m]));
    for (int j = 0; j < COLS; ++j)
    {
        table[m][j] = (table_info*)malloc(DEPTH * sizeof(table[m][j]));
        for (int k = 0; k < DEPTH; ++k)
        {
            table[m][j][k].size = 0;
            strcpy_s(table[m][j][k].code, sizeof(table[m][j][k].code), garb);
            memcpy(table[m][j][k].path, garb_path, sizeof(garb_path));
        }
    }
}
Am I initializing it correctly? or what should I correct to make it work?
 
     
    