I'm working on a display interface with C. Here is the simplified code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define A_BITMAP {1,2,3}
void getA(int **a){
a[0]=(int*)malloc(12);
memcpy(a[0],(int[])A_BITMAP,12);
}
void main(){
int* a;
getA(&a);
printf("%d",a[2]);
free(a);
}
A_BITMAP
is one picture's bitmap array, and I cannot modify its code. Here is my question:
Is there any way not using
memcpy()
to assign to the malloc(ed) area with macroA_BITMAP
?Will
(int[])A_BITMAP
generate a large local array on stack? The picture's size is about 2M, is it safe to do so?