]> sigrok.org Git - libsigrokdecode.git/commitdiff
Use g_try_malloc/g_free/g_strdup consistently.
authorUwe Hermann <redacted>
Sat, 11 Feb 2012 19:06:46 +0000 (20:06 +0100)
committerUwe Hermann <redacted>
Sat, 11 Feb 2012 21:34:16 +0000 (22:34 +0100)
Avoid plain malloc()/free() in sr/srd, especially in the API calls.
Also avoid g_malloc*() in favor of g_try_malloc*().

Use g_strdup() instead of strdup() so that we can use g_free()
consistently everywhere.

Exceptions: Stuff that is allocated via other libs (not using glib),
should also be properly free'd using the respective free-ing function
(instead of g_free()). Examples: Stuff allocated by libusb, libftdi, etc.

Also, use sr_err() instead of sr_warn() for actual errors. sr_warn() is
meant for non-fatal/uncritical warnings.

util.c

diff --git a/util.c b/util.c
index 27a5e07574cbc0f8e5a31c4df8d72f1cf28d1ace..cd77fc10481836aa3c9057e0d06a3360cecd9135 100644 (file)
--- a/util.c
+++ b/util.c
@@ -156,7 +156,7 @@ err_out:
 
 /**
  * Convert a Python list of unicode strings to a NULL-terminated UTF8-encoded
 
 /**
  * Convert a Python list of unicode strings to a NULL-terminated UTF8-encoded
- * char * array. The caller must free each string when finished.
+ * char * array. The caller must g_free() each string when finished.
  *
  * @param py_strlist The list object.
  * @param outstr ptr to char ** storage to be filled in.
  *
  * @param py_strlist The list object.
  * @param outstr ptr to char ** storage to be filled in.