X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Fgethostname.lisp;h=a6e1b0e1afe7c33686d9de534c52f5d85fdabaa5;hb=77378d36f07fe1f11893444217716b01628a329f;hp=909811487b39e8ad6b1421a24c71e820c0a52fb6;hpb=a95b9a217335917d96b8c0cced4f49c3e4846115;p=uffi.git diff --git a/tests/gethostname.lisp b/tests/gethostname.lisp index 9098114..a6e1b0e 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.3 2002/12/02 13:21:43 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -29,12 +29,13 @@ (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.")) + hostname)) (defun gethostname2 () "Returns the hostname"