dynamic arrays - is this right?

I'm creating a class that will allocate and manage a list of structs...
The struct is:
typedef struct tab_data_s {
// various struct elements
} tab_data_t, *tab_data_p ;

In my private data I have:
tab_data_p *tab_list ;

and my constructor is:
CTabControl::CTabControl(uint max_array_elements) :
tab_list = (tab_data_p *) new tab_data_p[max_elements] ;
ZeroMemory((char *) tab_list, max_elements * sizeof(tab_data_p)) ;

This compiles and runs successfully, but sizeof(tab_list) returns 4,
not (max_elements * sizeof(tab_data_p))...
That has me worried that I'm not really allocating an array of pointers, like I think I am... How can I ensure that I really allocated what I think I did??

sizeof(tab_list) is a pointer so it will return 4 bytes as it's size. I think you want to zero out max_elements * sizeof(tab_data_t);
It is correct because tab_list is declared as pointer to pointer to a structure.

tab_data_p *tab_list ;
Topic archived. No new replies allowed.