From 91a0d51705639cb0f5981a71c23f77c347b1c62c Mon Sep 17 00:00:00 2001
From: Juan Jose Garcia Ripoll <jjgarcia@users.sourceforge.net>
Date: Fri, 23 Apr 2010 22:29:02 +0200
Subject: [PATCH 2/4] Do not dealloc with FOREIGN-FREE the strings returned by my_strdup()

---
 tests/libtest.c       |    6 ++++++
 tests/misc-types.lisp |    8 +++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tests/libtest.c b/tests/libtest.c
index e5161c9..665f5d6 100644
--- a/tests/libtest.c
+++ b/tests/libtest.c
@@ -72,6 +72,12 @@ char *my_strdup(const char *str)
 }
 
 DLLEXPORT
+void my_free(const char *str)
+{
+    free(str);
+}
+
+DLLEXPORT
 long long my_llabs(long long n)
 {
     return n < 0 ? -n : n;
diff --git a/tests/misc-types.lisp b/tests/misc-types.lisp
index 98cba7d..86a8411 100644
--- a/tests/misc-types.lisp
+++ b/tests/misc-types.lisp
@@ -29,10 +29,12 @@
 
 (defcfun ("my_strdup" strdup) :string+ptr (str :string))
 
+(defcfun ("my_strfree" strfree) :void (str :string))
+
 (deftest misc-types.string+ptr
     (destructuring-bind (string pointer)
         (strdup "foo")
-      (foreign-free pointer)
+      (strfree pointer)
       string)
   "foo")
 
@@ -41,7 +43,7 @@
     (destructuring-bind (string pointer)
         (strdup (make-array 3 :element-type '(unsigned-byte 8)
                             :initial-contents (map 'list #'char-code "foo")))
-      (foreign-free pointer)
+      (strfree pointer)
       string)
   "foo")
 
@@ -124,7 +126,7 @@
 (deftest misc-types.wrapper
     (destructuring-bind (string ptr)
         (funky-strdup "code")
-      (foreign-free ptr)
+      (strfree ptr)
       string)
   "Strdup says: MORE CODE")
 
-- 
1.6.6.1

