| View previous topic :: View next topic |
| Author |
Message |
Stellar

Joined: 12 Dec 2005 Posts: 48
|
Posted: Thu Jan 12, 2006 1:02 pm Post subject: aligning data when allocating dynamically? |
|
|
the samples show how to align data when allocating data statically
ie..
static unsigned int __attribute__((aligned(16))) list[262144];
but what if you want to do it dynamically?
given the below, how could i modify the line to be 16 byte aligned?
MESH *pMesh;
... allocate mesh ...
pMesh->pVerticies = ( VTX ) calloc( sizeof( VTX ) , nVerticies );
______ structure definitions below_____________
| Code: |
typedef struct XlVertex
{
float u, v;
float x, y, z;
} *VTX; // 5 floats * 4 bytes = 20 bytes per vertex
typedef struct MeshNode
{
int nTriangles;
int nVerticies;
int nIndicies;
int nMeshId;
char szMeshName[256];
vtx pVerticies;
unsigned short *pIndicies;
MeshNode*pNext;
} *MESH;
|
thanks :) _________________
 |
|
| Back to top |
|
 |
ooPo Site Admin
Joined: 17 Jan 2004 Posts: 2032 Location: Canada
|
Posted: Thu Jan 12, 2006 2:49 pm Post subject: |
|
|
| Use memalign() to allocate aligned memory. |
|
| Back to top |
|
 |
Stellar

Joined: 12 Dec 2005 Posts: 48
|
Posted: Thu Jan 12, 2006 11:36 pm Post subject: |
|
|
thanks ooPo :) _________________
 |
|
| Back to top |
|
 |
|