From: Kevin M. Rosenberg Date: Mon, 25 Nov 2002 19:04:57 +0000 (+0000) Subject: r3485: *** empty log message *** X-Git-Tag: v1.6.1~253 X-Git-Url: http://git.kpe.io/?a=commitdiff_plain;h=68c9dd9a413f27118f5064200b6a85a52b865d23;hp=04b9dd33bd3a19781998caa959feb926c1fbfe5f;p=uffi.git r3485: *** empty log message *** --- 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"