Re: Malloc()
Re: Malloc()
- Subject: Re: Malloc()
- From: Markus Hitter <email@hidden>
- Date: Tue, 2 Apr 2002 12:09:55 +0200
Am Dienstag den, 2. April 2002, um 09:21, schrieb Pete Yandell:
As a counterexample, sizeof will do the right thing for
statically allocated data, so if you declare buffer as:
char buffer[129];
then sizeof(buffer) will give you the expected 129 ...
... or a number slightly above this.
Usually, memory is aligned for fast access a the cost of wasting
a few bytes. For example, this struct gives me a size of 52
bytes instead of the expected 50 bytes:
typedef struct {
float p1[3];
float p2[3];
float p3[3];
float normal[3];
char fill[2];
} triangle;
You have to take care of this difference when writing binary
data to files, for example.
There are some undocumented #pragma directives to influence this
alignment.
Have fun,
Markus
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: | |
| >Re: Malloc() (From: Pete Yandell <email@hidden>) |