c++ - memory overlapping in an initialization of a class -


my problem have header file in store classes , in cpp file have initializations of these classes, initialization not dynamic have number of arrays of different classes.

now problem when started expanding classes in header, adding more members , methods,the initialization of 1 specific class start throwing assertions @ me of memory overlapping , suggested using memmove() instead of memcpy(), though use neither of them in class.

i tried replacing class downgraded version of worked in older versions of source still threw same assertion @ me don't know part of code relevant here assertion being asserted in initialization of class without pointer wrong.

this initialization of class :

shuriken(cpfloat m,cpvect veloc,cpfloat elast,cpfloat myu) : spark() , bang1() , shurikenflame() { smass = m; sv = veloc; se = elast; su = myu; todraw = false; removed = true; allocatedbombanim = false; drawflamedshuriken = false; deployflamebang = false; passedline = false; hitfruit = false; fruitisbeinghit = false; toremovebody = false; dummyadded = false; hitbossbanana = false; fruitnum = 11;//11 means has no fruit sec_flamecounter = 3;  litshuriken_uvs[0] = ciwfvec2(0, 0); litshuriken_uvs[2] = ciwfvec2(1.0/4, 1.0/4); litshuriken_uvs[3] = ciwfvec2(1.0/4, 0); litshuriken_uvs[1] = ciwfvec2(0, 1.0/4);  sparkle_uvs[0] = ciwfvec2(0, 0); sparkle_uvs[2] = ciwfvec2(1.0/2, 1.0/4); sparkle_uvs[3] = ciwfvec2(1.0/2, 0); sparkle_uvs[1] = ciwfvec2(0, 1.0/4);  lastpos = cpvzero; lastangle = 0;  struct cpvect initshurikenbody_verts[35] =  {     cpv(-128.01,41.26),     cpv(-58.74,45.42),     cpv(-47.79,32.04),     cpv(-40.06,33.94),     cpv(-20.63,48.29),     cpv(-16.13,55.67),     cpv(-25.33,69.7),     cpv(0,134.67),     cpv(25.34,70.16),     cpv(16.14,55.67),     cpv(20.75,48.1),     cpv(39.98,34.04),     cpv(47.96,32.15),     cpv(58.86,45.38),     cpv(128.01,41.26),     cpv(74.55,-2.82),     cpv(57.95,1.45),     cpv(52.25,-5.19),     cpv(45.16,-26.79),     cpv(45.77,-35.34),     cpv(61.86,-41.64),     cpv(79.1,-108.95),     cpv(20.79,-71.41),     cpv(19.62,-54.33),     cpv(11.91,-51.14),     cpv(-12.02,-51.11),     cpv(-19.64,-54.26),     cpv(-20.81,-71.4),     cpv(-79.11,-108.95),     cpv(-61.87,-41.6),     cpv(-45.77,-35.03),     cpv(-45.18,-26.75),     cpv(-52.23,-5.35),     cpv(-57.88,1.31),     cpv(-74.48,-2.8), };   struct cpvect initshurikenshape_verts1[5] =   {     cpv(-128.01,41.26),     cpv(-58.74,45.42),     cpv(-47.79,32.04),     cpv(-57.88,1.31),     cpv(-74.48,-2.8),  };  struct cpvect initshurikenshape_verts2[5] =   {     cpv(0,134.67),     cpv(25.34,70.16),     cpv(16.14,55.67),     cpv(-16.13,55.67),     cpv(-25.33,69.7),  };  struct cpvect initshurikenshape_verts3[5] =   {     cpv(47.96,32.15),     cpv(58.86,45.38),     cpv(128.01,41.26),     cpv(74.55,-2.82),     cpv(57.95,1.45),  };  struct cpvect initshurikenshape_verts4[5] =   {     cpv(79.1,-108.95),     cpv(20.79,-71.41),     cpv(19.62,-54.33),     cpv(45.77,-35.34),     cpv(61.86,-41.64),  };  struct cpvect initshurikenshape_verts5[5] =   {     cpv(-79.11,-108.95),     cpv(-61.87,-41.6),     cpv(-45.77,-35.03),     cpv(-19.64,-54.26),     cpv(-20.81,-71.4),  };  struct cpvect initshurikenshape_verts6[4] =   {     cpv(-47.79,32.04),     cpv(-40.06,33.94),     cpv(-52.23,-5.35),     cpv(-57.88,1.31),  };  struct cpvect initshurikenshape_verts7[4] =   {     cpv(-20.63,48.29),     cpv(-16.13,55.67),     cpv(16.14,55.67),     cpv(20.75,48.1),  };  struct cpvect initshurikenshape_verts8[4] =   {     cpv(39.98,34.04),     cpv(47.96,32.15),     cpv(57.95,1.45),     cpv(52.25,-5.19),  };  struct cpvect initshurikenshape_verts9[4] =   {     cpv(45.16,-26.79),     cpv(45.77,-35.34),     cpv(19.62,-54.33),     cpv(11.91,-51.14),  };  struct cpvect initshurikenshape_verts10[4] =   {     cpv(-12.02,-51.11),     cpv(-19.64,-54.26),     cpv(-45.77,-35.03),     cpv(-45.18,-26.75),  };  struct cpvect initshurikenshape_verts11[10] =   {     cpv(-40.06,33.94),     cpv(-20.63,48.29),     cpv(20.75,48.1),     cpv(39.98,34.04),     cpv(52.25,-5.19),     cpv(45.16,-26.79),     cpv(11.91,-51.14),     cpv(-12.02,-51.11),     cpv(-45.18,-26.75),     cpv(-52.23,-5.35),  };  for(int i=0;i<5;i++)     shurikenshape_verts1[i] = initshurikenshape_verts1[i]; for(int i=0;i<5;i++)     shurikenshape_verts2[i] = initshurikenshape_verts2[i]; for(int i=0;i<5;i++)     shurikenshape_verts3[i] = initshurikenshape_verts3[i]; for(int i=0;i<5;i++)     shurikenshape_verts4[i] = initshurikenshape_verts4[i]; for(int i=0;i<5;i++)     shurikenshape_verts5[i] = initshurikenshape_verts5[i]; for(int i=0;i<4;i++)     shurikenshape_verts6[i] = initshurikenshape_verts6[i]; for(int i=0;i<4;i++)     shurikenshape_verts7[i] = initshurikenshape_verts7[i]; for(int i=0;i<4;i++)     shurikenshape_verts8[i] = initshurikenshape_verts8[i]; for(int i=0;i<4;i++)     shurikenshape_verts9[i] = initshurikenshape_verts9[i]; for(int i=0;i<4;i++)     shurikenshape_verts10[i] = initshurikenshape_verts10[i]; for(int i=0;i<10;i++)     shurikenshape_verts11[i] = initshurikenshape_verts11[i]; for(int i=0;i<35;i++)     shurikenbody_verts[i] = initshurikenbody_verts[i]; } 

i using visual studio 2010 marmalade sdk , writing in c++.

thanks help,

anton

ok, if assume shurikenshape_verts1 either regular c style array or c++ style std::array , has type cpvect, , cpvect pod struct:

for(int i=0;i<5;i++)     shurikenshape_verts1[i] = initshurikenshape_verts1[i]; 

can copied as:

memcpy(shurikenshape_verts1, initshurikenshape_verts1,         sizeof(initshurikenshape_verts1)); 

however, have made assumptions here, since haven't posted enough code. i'd hate start "can post this, can post that" type thread, asking large number of other bits of code, means may not have answered question correctly, since don't know sure cpvect indeed pod struct, example.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -