From c700613b8d463212d142c97108b7a2352e23e559 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 2 Feb 2012 15:45:54 -0700 Subject: 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. --- python/Makefile.am | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'python/Makefile.am') diff --git a/python/Makefile.am b/python/Makefile.am index 81b160aea..9b791d77c 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -7,9 +7,13 @@ SUBDIRS= . tests INCLUDES = \ $(PYTHON_INCLUDES) \ + -I$(top_builddir)/gnulib/lib \ + -I$(top_srcdir)/gnulib/lib \ + -I$(top_builddir)/src \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/util \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ - -I$(top_builddir)/$(subdir) \ $(GETTEXT_CPPFLAGS) AM_CFLAGS = $(WARN_CFLAGS) @@ -35,8 +39,14 @@ EXTRA_DIST = \ $(DOCS) if WITH_PYTHON -mylibs = $(top_builddir)/src/libvirt.la -myqemulibs = $(top_builddir)/src/libvirt-qemu.la +mylibs = \ + $(top_builddir)/src/libvirt.la \ + $(top_builddir)/src/libvirt_util.la \ + $(top_builddir)/gnulib/lib/libgnu.la +myqemulibs = \ + $(top_builddir)/src/libvirt-qemu.la \ + $(top_builddir)/src/libvirt_util.la \ + $(top_builddir)/gnulib/lib/libgnu.la all-local: libvirt.py libvirt_qemu.py @@ -46,7 +56,7 @@ libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c nodist_libvirtmod_la_SOURCES = libvirt.c libvirt.h # Python <= 2.4 header files contain a redundant decl, hence we # need extra flags here -libvirtmod_la_CFLAGS = $(WARN_PYTHON_CFLAGS) +libvirtmod_la_CFLAGS = $(WARN_CFLAGS) $(WARN_PYTHON_CFLAGS) libvirtmod_la_LDFLAGS = -module -avoid-version -shared -L$(top_builddir)/src/.libs \ $(CYGWIN_EXTRA_LDFLAGS) -- cgit v1.2.3-65-gdbad