X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=examples%2Fgethostname.lisp;h=2f9a261e8dc2fe3bc97c772a29b9faf1d23e6e6f;hb=87acde9ae931ba8ac7bd486809f6dab3b2448790;hp=909811487b39e8ad6b1421a24c71e820c0a52fb6;hpb=a95b9a217335917d96b8c0cced4f49c3e4846115;p=uffi.git diff --git a/examples/gethostname.lisp b/examples/gethostname.lisp index 9098114..2f9a261 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$ ;;;; ;;;; 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"