This may be a common trick used in C programming, but it's hard to tell without seeing the context it is used in. I am referring to the practice of allocating a struct with arbitrary number of elements dynamically without need to treat it as a pointer, or the overhead of even having a pointer:
texarray* foo(std::size_t sz) {
texarray* pta = reinterpret_cast<texarray*>(new texture[sz]);
for (std::size_t i = 0; i < sz; ++i) {
strcpy(pta->mode[i], "undefined");
}
return pta;
}
void bar(textarray* pta) {
delete [] reinterpret_cast<texture*>(pta);
}
int main() {
textarray* p = foo(15);
bar(p);
return 0;
}
Note that this trick usually requires a special function to release the memory correctly again, or else you'll end up with memory leaks or, worse, run-time errors.