On Wed, Dec 21, 2011 at 6:39 PM, caox <caox@...> wrote:
hmm... I found it in the header file "neo_err.h":/* function: nerr_log_error* description: currently, this prints out the error to stderr, and* free's the error chain*/void nerr_log_error (NEOERR *err);
Ah, the comment was fixed:
Besides, I didn't find any explicit release action of neo_err in the test code like:part of "hdf_test.c" under util/test/int main(int argc, char **argv){NEOERR *err;err = dictionary_test();if (err){nerr_log_error(err);printf("FAIL\n");return -1;}printf("PASS\n");return 0;}If I didn't misunderstand the src code, the neo_err *err is allocated and initialized during nerr_rasie and nerr_pass, but where does the test code free it?
It doesn't, just sloppy I guess.
Brandon
On 2011-12-22, at 上午3:18, Brandon Long wrote:I don't think any of those free the error chain, where did you get that impression? Its not in the api docs, as near as I can tell.BrandonOn Tue, Dec 20, 2011 at 10:28 PM, caox <caox@...> wrote:
HiSorry to bother. According to the description and code example, the API nerr_log_error should free the err chain. But I didn't find the respective code to release the err chain inside the implementation:void nerr_log_error (NEOERR *err){NEOERR *more;char buf[1024];char *err_name;if (err == STATUS_OK)return;if (err == INTERNAL_ERR){ne_warn ("Internal error");return;}more = err;fprintf (stderr, "Traceback (innermost last):\n");while (more && more != INTERNAL_ERR){err = more;more = err->next;if (err->error != NERR_PASS){NEOERR *r;if (err->error == 0){err_name = buf;snprintf (buf, sizeof (buf), "Unknown Error");}else{r = uListGet (Errors, err->error - 1, (void *)&err_name);if (r != STATUS_OK){err_name = buf;snpri ntf (buf, sizeof (buf), "Error %d", err->error);}}fprintf (stder r, " File \"%s\", line %d, in %s()\n%s: %s\n", err->file,err->lineno, err->func, err_name, err->desc);}else{fprintf (stderr, " File \"%s\", line %d, in %s()\n", err->file,err->lineno, err->func);if (err->desc[0]){fprintf (stderr, " %s\n", err->desc);}}}}So, is the err chain freed in other place or I have missed something inside the function? Does nerr_log_error free the err chain, as for nerr_err_string and nerr_err_traceback?Thanks.
B.R.