我替换了以下代码
(*dataset_p)[*term_count_p - 9] = ERL_DRV_ATOM;
(*dataset_p)[*term_count_p - 8] = drv->atom_error;
(*dataset_p)[*term_count_p - 7] = ERL_DRV_INT;
(*dataset_p)[*term_count_p - 6] = error_code;
(*dataset_p)[*term_count_p - 5] = ERL_DRV_STRING;
(*dataset_p)[*term_count_p - 4] = (ErlDrvTermData) error;
(*dataset_p)[*term_count_p - 3] = strlen(error);
(*dataset_p)[*term_count_p - 2] = ERL_DRV_TUPLE;
(*dataset_p)[*term_count_p - 1] = 3;
(其中dataset_p
有类型ErlDrvTermData**
并且term_count_p
是int*
)
append_to_dataset(9, *dataset_p, *term_count_p,
ERL_DRV_ATOM, drv->atom_error,
ERL_DRV_INT, error_code,
ERL_DRV_STRING, (ErlDrvTermData) error, strlen(error),
ERL_DRV_TUPLE, 3);
其中append_to_dataset
定义为
void append_to_dataset(int n, ErlDrvTermData* dataset, int term_count, ...) {
int i;
va_list new_terms;
va_start(new_terms, term_count);
for (i = -n; i < 0; i++) {
dataset[term_count + i] = va_arg(new_terms, ErlDrvTermData);
}
va_end(new_terms);
}
(差异看出这是全部差异)。在我看来,行为应该完全相同,但是当测试通过原始代码时,新版本失败并显示错误消息:
HUGE size (47278999994405)
make: *** [test] Aborted
我怎么了?