Home > Back-end >  C the vector memory puzzling is full
C the vector memory puzzling is full

Time:09-16

A class:
{
 class the PPPPublic: 
Omitted * * * * * *
Float WL_FCB [MAX_SYS_NUM] [MAX_GPS_SAT];/* variable WL_FCB */
Vector NL_FCB;/* variable NL_FCB */

Private:
Omitted * * * * * *
};

In a function assignment:
 
Int read_myfcb (cstrings & amp; Myfcbpath, float WL_FCB [MAX_SYS_NUM] [MAX_GPS_SAT], vector & NL_FCB) {
//open the file
Omitted * * * * * *

WL/* */
While (true) first while {/* */
Omitted * * * * * *
If (fline. Find (_T (" WL ")) & gt;=0) {
WL_FCB [SYS (fline [4])] [_ttoi (fline. The mids (5, 2))]=_ttof (fline. The mids (10, 10));/* to */WL_FCB assignment
}
}
NL/* */
While (true)/second while * */
{
Omitted * * * * * *
}

Readfile. Close ();
return 1;
}


Strange place:
When the function in the first while (line 6) function, NL_FCB size is 0, normal; But when the function to run to the second while function (line 13), the size of the NL_FCB suddenly become 67922558,

In the first while no to manipulate
the NL_FCB
modify two places can be normal:
One is the class of WL_FCB with NL_FCB the definition of a transfer order
The second is to WL_FCB assignment statements annotations, namely the function line 9

CodePudding user response:

Should be WL_FCB subscript bounds, WL_FCB [SYS (fline [4])] [_ttoi (fline. The mids (5, 2))]
Look at the two SYS (fline [4]), _ttoi (fline. The mids (5, 2)) if there is a cross-border 0, 0 - MAX_GPS_SAT MAX_SYS_NUM - 1-1

CodePudding user response:

WL
/* */
While (true) first while {/* */
Omitted * * * * * *
If (fline. Find (_T (" WL ")) & gt;=0) {
WL_FCB [SYS (fline [4])] [_ttoi (fline. The mids (5, 2))]=_ttof (fline. The mids (10, 10));/* to */WL_FCB assignment
}
}

Recommend that look after the comments,

CodePudding user response:

Estimation is a dead cycle, the result of a memory Buffer cross-border
  • Related