[plt-scheme] scheme/foreign and C arrays

From: Ben Simon (benjisimon at gmail.com)
Date: Thu Dec 25 18:44:53 EST 2008

Howdy -

Now that my MySQL FFI implementation doesn't crash every few moments, I've
been able to make some headway into making the API useful.  This has been
going well, until I hit the row handling MySQL requires. Here's the C
example they provide:

unsigned int num_fields;
unsigned int i;

num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result)))
   unsigned long *lengths;
   lengths = mysql_fetch_lengths(result);
   for(i = 0; i < num_fields; i++)
       printf("[%.*s] ", (int) lengths[i],
              row[i] ? row[i] : "NULL");

Apparently, when I call mysql_fetch_row(...) it will return back a big array
of character data that is the series of columns.  I can index into this
array by calling mysql_num_fields and mysql_fetch_lengths.

mysql_fetch_lengths returns back  an array of numbers, while the row object
is essentially an array.

Given this, I think I need to focus on how Scheme handles C arrays.  What's
the cleanest way to handle this?   I've found some discussion about
cvectors, is that I'm looking for?


Have an idea for software?  I can make it happen -
My Blog: http://benjisimon.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20081225/962773b8/attachment.html>

Posted on the users mailing list.