Commits

llibra committed 8c78185

Refactored LVDB.DB:OPEN.

  • Participants
  • Parent commits 678f603

Comments (0)

Files changed (1)

 (in-package :lvdb.db)
 
 (defun open (opt name)
-  (with-foreign-string (name-ptr name)
-    (with-foreign-object (err-ptr :pointer)
-      (setf (mem-aref err-ptr :pointer) (null-pointer))
-      (let ((db (leveldb-open opt name-ptr err-ptr)))
-        (if (null-pointer-p db)
-            (let ((ptr (mem-aref err-ptr :pointer)))
-              (unwind-protect (error (foreign-string-to-lisp ptr))
-                (free ptr)))
-            db)))))
+  (with-foreign-string (name-fs name)
+    (with-error-pointer (err-ptr)
+      (prog1 (leveldb-open opt name-fs err-ptr)
+        (handle-error-pointer err-ptr)))))
 
 (defun close (db)
   (leveldb-close db))