Is there a way to use poiter arithmetic on a large malloc block, so you can assign multiple structs or primitive data types to that area already allocated? I'm writing something like this but it isnt working (trying to assign 200 structs to a 15000byte malloc area):
char *primDataPtr = NULL;
typedef struct Metadata METADATA;
struct Metadata {
.
.
.
};/*struct Metadata*/
.
.
.
primDataPtr = (void*)(malloc(15000));
if(primDataPtr == NULL) {
exit(1);
}
char *tempPtr = primDataPtr;
int x;
for(x=0;x<200;x++) {
METADATA *md = (void*)(primDataPtr + (sizeof(METADATA) * x));
}//end x -for