[xml] Memory leak or stupid newbie error?
- From: Ian Pilcher <pilchman attbi com>
- To: xml gnome org
- Subject: [xml] Memory leak or stupid newbie error?
- Date: Thu, 28 Feb 2002 23:17:37 -0600
I'm a brand new user of libxml (and XML), so appologies in advance if
this is a really stupid question.
I've found that a simple program which parses a DTD file and immediately
frees it is leaking memory. Here is my program. (BTW, this is Red Hat
Linux 7.2, libxml 2.4.10.)
#include <libxml/parser.h>
#include <stdlib.h>
#include <stdio.h>
#include <mcheck.h>
int main(int argc, char *argv[])
{
xmlDtdPtr dtd;
mtrace();
if (argc < 2)
{
fprintf(stderr, "Usage: %s <DTD file>\n", argv[0]);
exit(__LINE__);
}
dtd = xmlParseDTD(NULL, argv[1]);
if (dtd == NULL)
{
fprintf(stderr, "%s: xmlParseDTD failed\n", argv[1]);
exit(__LINE__);
}
xmlFreeDtd(dtd);
return 0;
}
Here is the DTD file.
<!ELEMENT atom (value, packages)>
<!ATTLIST atom type (ATOM_STRING | ATOM_LIST | ATOM_INT | ATOM_BIN)
#REQUIRED>
<!ELEMENT value (string_data | list_data | int_data | bin_data)>
<!ELEMENT string_data (#PCDATA)>
<!ELEMENT list_data (item)*>
<!ELEMENT item (#PCDATA)>
<!ELEMENT int_data (#PCDATA)>
<!ELEMENT bin_data (#PCDATA)>
<!ELEMENT packages (package)*>
<!ELEMENT package (#PCDATA)>
(The ATTLIST line is being wrapped by my e-mail client; it's one line in
the file.)
Is there something else that I should be doing?
Thanks!
--
========================================================================
Ian Pilcher pilchman attbi com
========================================================================
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]