I can allocate memory for pointer to struct bmp_ptr
and I can check if the pointer is valid. But I need to allocate memory for header
or dib
member, how could I check that the malloc()
was successful? I can malloc()
, but using type cast means that the resulting pointer from malloc()
would disappear. How could I declare the nested type?
header:
typedef struct BMP_DIB BITMAPINFOHEADER;
// BMP_DIB definition follows..
// BMP_FILE_struct definition follows:
typedef struct BMP_FILE_struct {
BMPHEADER header;
BITMAPINFOHEADER dib;
} BMPFILE;
main inside function:
BMPFILE * bmp_ptr;
bmp_ptr = malloc(sizeof(BMPFILE));
if (bmp_ptr == NULL) return NULL;