r3485: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 25 Nov 2002 19:04:57 +0000 (19:04 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 25 Nov 2002 19:04:57 +0000 (19:04 +0000)
examples/gethostname.lisp
tests/gethostname.lisp

index 909811487b39e8ad6b1421a24c71e820c0a52fb6..04fa7973a89d7184f1cde852fd790625f7b6f4d3 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: gethostname.lisp,v 1.1 2002/09/30 10:02:36 kevin Exp $
+;;;; $Id: gethostname.lisp,v 1.2 2002/11/25 19:04:57 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 (defun gethostname ()
   "Returns the hostname"
   (let* ((name (uffi:allocate-foreign-string 256))
-        (result (c-gethostname name 256)))
-    (unwind-protect
-       (if (zerop result)
-           (uffi:convert-from-foreign-string name)
-         (error "gethostname() failed."))
-      (uffi:free-foreign-object name))))
+        (result-code (c-gethostname name 256))
+        (hostname (when (zerop result-code)
+                    (uffi:convert-from-foreign-string name))))
+    (uffi:free-foreign-object name)
+    (unless (zerop result-code)
+      (error "gethostname() failed."))))
 
 (defun gethostname2 ()
   "Returns the hostname"
index 909811487b39e8ad6b1421a24c71e820c0a52fb6..04fa7973a89d7184f1cde852fd790625f7b6f4d3 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: gethostname.lisp,v 1.1 2002/09/30 10:02:36 kevin Exp $
+;;;; $Id: gethostname.lisp,v 1.2 2002/11/25 19:04:57 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 (defun gethostname ()
   "Returns the hostname"
   (let* ((name (uffi:allocate-foreign-string 256))
-        (result (c-gethostname name 256)))
-    (unwind-protect
-       (if (zerop result)
-           (uffi:convert-from-foreign-string name)
-         (error "gethostname() failed."))
-      (uffi:free-foreign-object name))))
+        (result-code (c-gethostname name 256))
+        (hostname (when (zerop result-code)
+                    (uffi:convert-from-foreign-string name))))
+    (uffi:free-foreign-object name)
+    (unless (zerop result-code)
+      (error "gethostname() failed."))))
 
 (defun gethostname2 ()
   "Returns the hostname"