malloc时触发断点
程序代码:
void QueueAppend(LQueue *Q, int x) { LQNode *p = (LQNode *)malloc(sizeof(LQNode));++++++++++++++++++++++++++++ p->data = x; p->next = NULL; if(Q->rear != NULL) Q->rear->next = p; Q->rear = p; if(Q->rear == NULL) Q->front == p; }
程序代码:
void RadixSort(int *a,int n, int m,int d) { int i, j, k, power = 1; LQueue *tub; tub = (LQueue *)malloc(sizeof (LQueue )* d); for(i = 0; i < d; i++) QueueInitiate(&tub[i]); for(i = 0; i < m; i++){ if(i == 0) power = 1; else power = power *d; for(j = 0; j < n; j++){ k = a[j] /power - (a[j] /(power * d)) * d; QueueAppend(&tub[k], a[j]); } k = 0; for(j = 0; j < d; j++) while(QueueNotEmpty(tub[j]) != 0){ QueueDelete(&tub[j], &a[k]);++++++++++++++++++++++ k++; } } }
RadixSort函数调用QueueAppend时,+++++++++++++++++标志的语句触发了断点。我在main函数中直接调用QueueAppend函数时却没有触发。编译器是vs2012