summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Bex <peter@more-magic.net>2024-09-12 19:39:16 +0200
committerPeter Bex <peter@more-magic.net>2024-09-12 19:39:16 +0200
commit8ff1920c22d99913318f0d17902f53b27cb82727 (patch)
tree0d55de184020363effe42c2e0a207d2fdf062162
parente0f990b4efde2e73e5afc01ea531bf987c69a277 (diff)
downloadchicken-postgresql-8ff1920c22d99913318f0d17902f53b27cb82727.tar.gz
Use bytevector foreign type instead of bare scheme-pointerHEADmaster
This provides a little bit more safety in case we need to change this again later.
-rw-r--r--postgresql.scm18
1 files changed, 9 insertions, 9 deletions
diff --git a/postgresql.scm b/postgresql.scm
index 801df81..e6d654c 100644
--- a/postgresql.scm
+++ b/postgresql.scm
@@ -141,11 +141,11 @@
(define PQcmdTuples (foreign-lambda nonnull-c-string PQcmdTuples pgresult*))
(define PQoidValue (foreign-lambda oid PQoidValue pgresult*))
-(define PQputCopyData (foreign-lambda int PQputCopyData pgconn* scheme-pointer int))
+(define PQputCopyData (foreign-lambda int PQputCopyData pgconn* bytevector int))
(define PQputCopyEnd (foreign-lambda int PQputCopyEnd pgconn* (const c-string)))
(define PQgetCopyData (foreign-lambda int PQgetCopyData pgconn* (c-pointer (c-pointer char)) bool))
-(define memcpy (foreign-lambda c-pointer "C_memcpy" nonnull-scheme-pointer c-pointer size_t))
+(define memcpy (foreign-lambda c-pointer "C_memcpy" nonnull-bytevector c-pointer size_t))
;; TODO: Create a real callback system?
(foreign-declare "static void nullNoticeReceiver(void *arg, const PGresult *res){ }")
@@ -498,8 +498,8 @@
(cond-expand
(has-connectdb-params
(let ((len (length spec)))
- ((foreign-lambda* pgconn* ((scheme-object lst) (scheme-pointer keybuf)
- (scheme-pointer valbuf) (int len))
+ ((foreign-lambda* pgconn* ((scheme-object lst) (bytevector keybuf)
+ (bytevector valbuf) (int len))
"const char **key = (const char **)keybuf;"
"const char **val = (const char **)valbuf;"
"int i;"
@@ -996,8 +996,8 @@
(foreign-lambda*
bool ((pgconn* conn) (nonnull-c-string query)
(bool is_prepped) (int num) (scheme-object params)
- (scheme-pointer valsbuf) (scheme-pointer lensbuf)
- (scheme-pointer fmtsbuf) (int rfmt))
+ (bytevector valsbuf) (bytevector lensbuf)
+ (bytevector fmtsbuf) (int rfmt))
"int i = 0, *lens = (int *)lensbuf, *fmts = (int *)fmtsbuf;"
"const char **vals = (const char **)valsbuf;"
"C_word obj, cons;"
@@ -1188,7 +1188,7 @@
(define (escape-string conn str)
(define %escape-string-conn
(foreign-lambda size_t PQescapeStringConn
- pgconn* scheme-pointer scheme-pointer size_t (c-pointer bool)))
+ pgconn* bytevector bytevector size_t (c-pointer bool)))
(let-location ((err bool))
(let* ((strlen (string-length str))
(buflen (add1 (* strlen 2)))
@@ -1205,7 +1205,7 @@
(cond-expand
(has-escape-identifier
(define %escape-ident
- (foreign-lambda c-string* PQescapeIdentifier pgconn* scheme-pointer size_t))
+ (foreign-lambda c-string* PQescapeIdentifier pgconn* bytevector size_t))
(let ((len (string-length str)))
(or (%escape-ident (pg-connection-ptr conn) (##sys#slot str 0) len)
(postgresql-error 'internal 'quote-identifier
@@ -1220,7 +1220,7 @@
(define (escape-bytea conn obj)
(define %escape-bytea-conn
(foreign-lambda (c-pointer unsigned-char) PQescapeByteaConn
- pgconn* scheme-pointer size_t (c-pointer size_t)))
+ pgconn* bytevector size_t (c-pointer size_t)))
(let-location ((allocated size_t))
(let* ((conn-ptr (pg-connection-ptr conn))
(data (cond ((string? obj) (##sys#slot obj 0))