File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libxml2 / python / tests / tstmem.py
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jun 15 19:53:34 2014 UTC (10 years, 5 months ago) by misho
Branches: libxml2, MAIN
CVS tags: v2_9_1p0, v2_9_1, HEAD
libxml2 2.9.1

    1: #!/usr/bin/python -u
    2: import libxml2
    3: import libxml2mod
    4: import sys
    5: 
    6: def error(msg, data):
    7:     pass
    8: 
    9: # Memory debug specific
   10: libxml2.debugMemory(1)
   11: 
   12: dtd="""<!ELEMENT foo EMPTY>"""
   13: instance="""<?xml version="1.0"?>
   14: <foo></foo>"""
   15: 
   16: dtd = libxml2.parseDTD(None, 'test.dtd')
   17: ctxt = libxml2.newValidCtxt()
   18: libxml2mod.xmlSetValidErrors(ctxt._o, error, error)
   19: doc = libxml2.parseDoc(instance)
   20: ret = doc.validateDtd(ctxt, dtd)
   21: if ret != 1:
   22:     print("error doing DTD validation")
   23:     sys.exit(1)
   24: 
   25: doc.freeDoc()
   26: dtd.freeDtd()
   27: del dtd
   28: del ctxt
   29: 
   30: # Memory debug specific
   31: libxml2.cleanupParser()
   32: if libxml2.debugMemory(1) == 0:
   33:     print("OK")
   34: else:
   35:     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
   36:     libxml2.dumpMemory()

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>