delete [] astructure error

hello
The code below gives this error
"Heap block at 008E8248 modified at 008E8274 past requested size of 24
Windows has triggered a breakpoint in mmdCompiler.exe."

I believe, this is because I try to delete VERTEX_BONE structure, although I create a pointer to hold them (boneVertexAsign), members of structure are not pointer, so when I try to delete boneVertexAsign it gives this error, How can I fix it ?

Thank you for your help

1
2
3
4
5
6
7
8
struct VERTEX_BONE {
	char bone[MAX_NAME_LENGTH];
	int	vertex;
};

VERTEX_BONE* boneVertexAsign = (VERTEX_BONE*)malloc(sizeof(VERTEX_BONE)*skHeader.numberOfVertex);

delete [] boneVertexAsign;

You cannot use delete with malloc(), use free() instead.
instead of delete use free.
Or instead of malloc use new.

VERTEX_BONE* boneVertexAsign = new VERTEX_BONE[skHeader.numberOfVertex];
thank you for your replies, poblem solved
Topic archived. No new replies allowed.