summaryrefslogtreecommitdiffstats
path: root/typewrappers.c
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 /typewrappers.c
parent29aedfa4f48a9cc25d9049b7fc3ecd849147274b (diff)
downloadlibvirt-python-v6-77446a59e33b0c4be2ca8043feefc157842f1607.tar.gz
libvirt-python-v6-77446a59e33b0c4be2ca8043feefc157842f1607.tar.xz
libvirt-python-v6-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 'typewrappers.c')
-rw-r--r--typewrappers.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/typewrappers.c b/typewrappers.c
index 9021ce3..3f200b3 100644
--- a/typewrappers.c
+++ b/typewrappers.c
@@ -2,7 +2,7 @@
* types.c: converter functions between the internal representation
* and the Python objects
*
- * Copyright (C) 2005, 2007 Red Hat, Inc.
+ * Copyright (C) 2005, 2007, 2012 Red Hat, Inc.
*
* Daniel Veillard <veillard@redhat.com>
*/
@@ -16,6 +16,8 @@
#include "typewrappers.h"
+#include "memory.h"
+
#ifndef Py_CAPSULE_H
typedef void(*PyCapsule_Destructor)(void *, void *);
#endif
@@ -86,7 +88,7 @@ libvirt_charPtrSizeWrap(char *str, Py_ssize_t size)
return (Py_None);
}
ret = PyString_FromStringAndSize(str, size);
- free(str);
+ VIR_FREE(str);
return (ret);
}
@@ -100,7 +102,7 @@ libvirt_charPtrWrap(char *str)
return (Py_None);
}
ret = PyString_FromString(str);
- free(str);
+ VIR_FREE(str);
return (ret);
}