pea
developer
Hi guys,
I'm sure this has been asked before, but what is the best way to allocate memory for a structure? Let the compiler do it, or do it manually? Are there any differences?
Here is my example:
COMPILER DOES IT (tRGBA)
	
	
	
		
MANUAL (tRGBA)
	
	
	
		
Which is best? Is it best to just choose one and always use that? i am going to be creating 'records' and adding them to lists etc.
				
			I'm sure this has been asked before, but what is the best way to allocate memory for a structure? Let the compiler do it, or do it manually? Are there any differences?
Here is my example:
COMPILER DOES IT (tRGBA)
		Code:
	
	typedef struct {
	unsigned char red;
	unsigned char green;
	unsigned char blue;
	unsigned char alpha;
} tRGBA;
typedef struct {
	unsigned char ratio;
	tRGBA color;
} tRecord;
record = (tRecord*)malloc (sizeof(tRecord));
	MANUAL (tRGBA)
		Code:
	
	typedef struct {
	unsigned char red;
	unsigned char green;
	unsigned char blue;
	unsigned char alpha;
} tRGBA;
typedef struct {
	unsigned char ratio;
	tRGBA *color;
} tRecord;
record = (tRecord*)malloc (sizeof(tRecord));
record->color = (tRGBA*)malloc (sizeof(tRGBA));
	Which is best? Is it best to just choose one and always use that? i am going to be creating 'records' and adding them to lists etc.
	