Я анализирую документ XML с парсером SAX на С ++.
<A>
<B>
<S i='123'>
<S i='123'>
...
</B>
</A>
// C++ code ot represent the above XML in c++
typedef struct {
UINT32 i;
} S, *PS;
typedef struct {
PS pointersToS; // Planning to change this to deque.
UINT32 counter;
} B, *PB;
typedef struct {
PB pointersToB;
} A, *PA;
Старый код.
PA pointerA = (PA) MEMCALLOC(1,SIZEOF(A));
PB pointerB = (PB) MEMCALLOC(1,SIZEOF(B));
pointerA->pointersToB = pointerB;
PS pointerS = (PS) MEMCALLOC(10,SIZEOF(S));
pointerB.pointersToS = pointerS;
PS pointerS1 = (PS) MEMCALLOC(10,SIZEOF(S));
pointerS1.i=// reading from the xml.
pointerB->pointersToS[counter] = pointerS1;
pointerB.counter++;
PS pointerS2 = (PS) MEMCALLOC(1,SIZEOF(S));
pointerS2.i=// reading from the xml.
pointerB->pointersToS[counter] = pointerS2;
pointerB.counter++;
Вышеописанная реализация работала отлично.
Теперь я хочу представить deque.
typedef struct {
UINT32 i;
} S, *PS;
typedef struct {
std::deque<PS> queueToS;
} B, *PB;
typedef struct {
PB pointersToB;
} A, *PA;
PA pointerA = (PA) MEMCALLOC(1,SIZEOF(A));
PB pointerB = new PB();
pointerA->pointersToB = pointerB;
PS pointerS1 = (PS) MEMCALLOC(10,SIZEOF(S));
pointerS1.i=// reading from the xml.
pointerB->queueToS.push_back(pointerS1);
PS pointerS2 = (PS) MEMCALLOC(1,SIZEOF(S));
pointerS2.i=// reading from the xml.
pointerB->queueToS.push_back(pointerS2);
Я подозреваю, что причиной является новый оператор. Я получаю ошибку 0x14, когда я пытаюсь прочитать данные из deque.
Является ли подходящим использование deque? Я делаю этот анализ на уровне cpp и передаю обработчик на уровень Java. Когда вызов JNI поступает на уровень c ++ для доступа к данным внутри него, я получаю ошибку «signal 11 (SIGSEGV), code 1 (SEGV_MAPER), error addr 0xf4».
Я получаю эту ошибку только при попытке получить доступ к данным очереди. Я написал модульный тест для моего логина разбора, все дела работают нормально. Но вызов JNI приводит к ошибке.