Search the web
Sign In
New User? Sign Up
ClearSilver

Group Information

  • Members: 250
  • Category: Open Source
  • Founded: Jul 2, 2001
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

  Messages Help
Advanced
Does nerr_log_error free the NEO_ERR *   Message List  
Reply Message #1427 of 1429 |
Re: Does nerr_log_error free the NEO_ERR *



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.

Brandon

On Tue, Dec 20, 2011 at 10:28 PM, caox <caox@...> wrote:


Hi

Sorry 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.







Thu Dec 22, 2011 7:33 am

blong42
Online Now Online Now
Send Email Send Email

Message #1427 of 1429 |
Expand Messages Author Sort by Date

Hi Sorry 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...
caox
caox@... Send Email
Dec 21, 2011
6:28 am

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. Brandon...
Brandon Long
blong42 Online Now Send Email
Dec 21, 2011
7:18 pm

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 *...
caox
caox@... Send Email
Dec 22, 2011
2:39 am

... Ah, the comment was fixed: http://code.google.com/p/clearsilver/source/detail?spec=svn861&r=861 ... It doesn't, just sloppy I guess. Brandon ... On Wed,...
Brandon Long
blong42 Online Now Send Email
Dec 22, 2011
7:33 am

OK, I see. That means we need call nerr_ignore after nerr_log_error if we want the err chain to be freed correctly. Thanks. ... OK, I see. That means we need...
caox
caox@... Send Email
Dec 22, 2011
7:48 am
Advanced

Copyright 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help