Replace malloc with calloc in create_flat_labels

上级 661c27a4
...@@ -72,11 +72,11 @@ void create_flat_labels( PyArrayObject * label_matrix, int ** flat_labels, ...@@ -72,11 +72,11 @@ void create_flat_labels( PyArrayObject * label_matrix, int ** flat_labels,
npy_int rows = PyArray_DIMS( label_matrix )[0]; npy_int rows = PyArray_DIMS( label_matrix )[0];
npy_int cols = PyArray_DIMS( label_matrix )[1]; npy_int cols = PyArray_DIMS( label_matrix )[1];
*flat_labels = (int *) malloc( rows * cols * sizeof(int) ); *flat_labels = (int *) calloc( rows * cols, sizeof(int) );
if ( NULL == (*flat_labels) ) if ( NULL == (*flat_labels) )
return; return;
*label_lengths = (int *) malloc( rows * sizeof(int) ); *label_lengths = (int *) calloc( rows, sizeof(int) );
if ( NULL == (*label_lengths) ) if ( NULL == (*label_lengths) )
{ {
free( *flat_labels ); free( *flat_labels );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论