中止陷阱:6错误

时间:2015-04-07 16:01:58

标签: c

我有两个函数来移位类型P的字节,而另一个函数移位类型Q:

static const int vector_shift_Q_256[8] = {1,3,5,7,0,2,4,6};
static const int vector_shift_P_256[8] = {0,1,2,3,4,5,6,7};

void shiftBytes_Q_256(uint8_t block[8][8]) {
  uint8_t block_aux[8][8];

  for(i = 0; i < 8; i++) {
    for(j = 0; j < 8; j++) {
      if(j-(vector_shift_Q_256[i]) >= 0) 
            block_aux[i][j-(vector_shift_Q_256[i])] = block[i][j];
      else 
            block_aux[i][8+(j-(vector_shift_Q_256[i]))] = block[i][j];  
    }
  }
   memcpy(block,block_aux,L_256);
}  

void shiftBytes_P_256(uint8_t block[8][8]) {
  uint8_t block_aux[8][8];
  for(i = 0; i < 8; i++) {
    for(j = 0; j < 8; j++) {
        if(j-(vector_shift_P_256[i]) >= 0) 
            block_aux[i][j-(vector_shift_P_256[i])] = block[i][j];
        else 
            block_aux[i][8+(j-(vector_shift_P_256[i]))] = block[i][j];      
    }
  }
  memcpy(block,block_aux,L_256);
}

当我尝试为这两种类型(P和Q)创建一个函数时,我收到错误中止陷阱:6:

void shiftBytes_P_Q_256(uint8_t block_P[8][8],uint8_t block_Q[8][8]) {
  uint8_t block_aux_P[8][8];
  uint8_t block_aux_Q[8][8];

  for(i = 0; i < 8; i++) {
    for(j = 0; j < 8; j++) {
        if(j-(vector_shift_P_256[i]) >= 0) {
            block_aux_P[i][j-(vector_shift_P_256[i])] = block_P[i][j];
        }if(j-(vector_shift_P_256[i]) < 0) {
            block_aux_P[i][8+(j-(vector_shift_P_256[i]))] = block_P[i][j];
        }   

        if(j-(vector_shift_Q_256[i]) >= 0) {
            block_aux_Q[i][j-(vector_shift_Q_256[i])] = block_Q[i][j];
        } if(j-(vector_shift_Q_256[i]) < 0) {
            block_aux_Q[i][8+(j-(vector_shift_Q_256[i]))] = block_Q[i][j];
        }
    }
  } 
  memcpy(block_P,block_aux_P,L_256);
  memcpy(block_Q,block_aux_Q,L_256);
}

我想知道为什么这个函数导致了这个错误。

0 个答案:

没有答案