summaryrefslogtreecommitdiffstats
path: root/generator.py
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2012-02-02 15:45:54 -0700
committerEric Blake <eblake@redhat.com>2012-02-03 10:41:47 -0700
commit77446a59e33b0c4be2ca8043feefc157842f1607 (patch)
treee461f8212e1c9f58997afb29b9e8986c8de033f1 /generator.py
parent29aedfa4f48a9cc25d9049b7fc3ecd849147274b (diff)
downloadlibvirt-python-split-77446a59e33b0c4be2ca8043feefc157842f1607.tar.gz
libvirt-python-split-77446a59e33b0c4be2ca8043feefc157842f1607.tar.xz
libvirt-python-split-77446a59e33b0c4be2ca8043feefc157842f1607.zip
python: use libvirt_util to avoid raw free
This patch starts the process of elevating the python binding code to be on the same level as the rest of libvirt when it comes to requiring good coding styles. Statically linking against the libvirt_util library makes it much easier to write good code, rather than having to open-code and reinvent things locally. Done by global search and replace of s/free(/VIR_FREE(/, followed by hand-inspection of remaining malloc and redundant memset. * cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation): Remove python from exemption. * python/Makefile.am (INCLUDES): Add gnulib and src/util. Drop $(top_builddir)/$(subdir), as automake already guarantees that. (mylibs, myqemulibs): Pull in libvirt_util and gnulib. (libvirtmod_la_CFLAGS): Catch compiler warnings if configured to use -Werror. * python/typewrappers.c (libvirt_charPtrSizeWrap) (libvirt_charPtrWrap): Convert free to VIR_FREE. * python/generator.py (print_function_wrapper): Likewise. * python/libvirt-override.c: Likewise.
Diffstat (limited to 'generator.py')
-rwxr-xr-xgenerator.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/generator.py b/generator.py
index 0728519..98072f0 100755
--- a/generator.py
+++ b/generator.py
@@ -580,7 +580,7 @@ def print_function_wrapper(module, name, output, export, include):
if ret[0] == 'void':
if file == "python_accessor":
if args[1][1] == "char *":
- c_call = "\n free(%s->%s);\n" % (
+ c_call = "\n VIR_FREE(%s->%s);\n" % (
args[0][0], args[1][0], args[0][0], args[1][0])
c_call = c_call + " %s->%s = (%s)strdup((const xmlChar *)%s);\n" % (args[0][0],
args[1][0], args[1][1], args[1][0])