From 68c9dd9a413f27118f5064200b6a85a52b865d23 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 25 Nov 2002 19:04:57 +0000 Subject: [PATCH 1/1] r3485: *** empty log message *** --- examples/gethostname.lisp | 14 +++++++------- tests/gethostname.lisp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/gethostname.lisp b/examples/gethostname.lisp index 9098114..04fa797 100644 --- a/examples/gethostname.lisp +++ b/examples/gethostname.lisp @@ -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 ;;;; @@ -29,12 +29,12 @@ (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" diff --git a/tests/gethostname.lisp b/tests/gethostname.lisp index 9098114..04fa797 100644 --- a/tests/gethostname.lisp +++ b/tests/gethostname.lisp @@ -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 ;;;; @@ -29,12 +29,12 @@ (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" -- 2.34.1