Show
Ignore:
Timestamp:
05/25/09 05:47:51 (16 months ago)
Author:
sjamaan
Message:

Fix really bad bug; used pointer instead of c-pointer as argument type (damned compiler warnings didn't help)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • release/4/postgresql/trunk/postgresql.scm

    r14767 r14768  
    600600           "    }" 
    601601           "}" 
    602            "res = PQsendQueryParams(conn, query, num, NULL," 
    603            "                        vals, lens, fmts, resfmt);" 
     602           "res = PQsendQueryParams((PGconn *)conn, query, num, NULL," 
     603           "                        (const char * const *)vals, lens, fmts, resfmt);" 
    604604           "for (i=0,cons=params; i < num; ++i,cons=C_u_i_cdr(cons)) {" 
    605605           "    obj = C_u_i_car(cons);" 
     
    631631    ;; This can allocate up to twice as much memory than the string actually 
    632632    ;; uses; in extreme cases this could be a problem. 
    633     (foreign-lambda* c-string* ((pointer conn) (c-string from) (int fromlen)) 
     633    (foreign-lambda* c-string* ((pgconn* conn) (c-string from) (int flen)) 
    634634                     "int err = 0; char *to;" 
    635                      "to = malloc(sizeof(char) * (fromlen * 2 + 1));" 
    636                      "PQescapeStringConn(conn, to, from, fromlen, &err);" 
     635                     "to = malloc(sizeof(char) * (flen * 2 + 1));" 
     636                     "PQescapeStringConn((PGconn *)conn, to, from, (size_t)flen, &err);" 
    637637                     "if (err) {" 
    638638                     "        free(to);" 
     
    640640                     "}" 
    641641                     "C_return(to);")) 
    642   (or (%escape-string-conn conn str (string-length str)) 
     642  (or (%escape-string-conn (pg-connection-ptr conn) str (string-length str)) 
    643643      (postgresql-error 'escape-string 
    644644                        (conc "String escaping failed. " 
     
    648648  (define %escape-bytea-conn 
    649649    ;; This must copy because libpq returns a malloced ptr... 
    650     (foreign-safe-lambda* scheme-object ((pointer conn) 
     650    (foreign-safe-lambda* scheme-object ((pgconn* conn) 
    651651                                         ;; not copied/NUL interpreted: 
    652652                                         ((const unsigned-c-string*) from) 
    653                                          (int fromlen)) 
     653                                         (int flen)) 
    654654                     "size_t tolen=0; C_word res, *fin; unsigned char *esc;" 
    655                      "esc = PQescapeByteaConn(conn, from, (size_t)fromlen, &tolen);" 
     655                     "esc = PQescapeByteaConn((PGconn *)conn, from, (size_t)flen, &tolen);" 
    656656                     "if (esc == NULL)" 
    657                      "        C_return(C_SCHEME_FALSE);" 
     657                     "    C_return(C_SCHEME_FALSE);" 
    658658                     "fin = C_alloc(C_bytestowords(tolen + sizeof(C_header)));" 
    659659                     "/* tolen includes the resulting NUL byte */" 
     
    661661                     "PQfreemem(esc);" 
    662662                     "C_return(res);")) 
    663   (or (%escape-bytea-conn conn str (string-length str)) 
     663  (or (%escape-bytea-conn (pg-connection-ptr conn) str (string-length str)) 
    664664      (postgresql-error 'escape-bytea 
    665665                        (conc "Byte array escaping failed. " 
     
    673673                     "unesc = PQunescapeBytea(from, &tolen);" 
    674674                     "if (unesc == NULL)" 
    675                      "        C_return(C_SCHEME_FALSE);" 
     675                     "    C_return(C_SCHEME_FALSE);" 
    676676                     "fin = C_alloc(C_bytestowords(tolen + sizeof(C_header)));" 
    677677                     "res = C_string(&fin, tolen, (char *)unesc);"