ext/amalgalite3_blob.c in amalgalite-0.2.4 vs ext/amalgalite3_blob.c in amalgalite-0.4.0
- old
+ new
@@ -37,24 +37,23 @@
/* make sure that the flags are valid, only 'r' or 'w' are allowed */
if ( ( RSTRING( flag_str )->len != 1) ||
( ( 'r' != RSTRING( flag_str )->ptr[0] ) &&
( 'w' != RSTRING( flag_str )->ptr[0] ))) {
- rb_raise( eAS_Error, "Error opening Blob in db = %s, table = %s, column = %s, rowid = %d. Invalid flag '%s'. Must be either 'w' or 'r'\n",
- zDb, zTable, zColumn, iRow, RSTRING( flag_str )->ptr);
+ rb_raise( eAS_Error, "Error opening Blob in db = %s, table = %s, column = %s, rowid = %lu. Invalid flag '%s'. Must be either 'w' or 'r'\n",
+ zDb, zTable, zColumn, (unsigned long)iRow, RSTRING( flag_str )->ptr);
}
/* switch to write mode */
if ( 'w' == RSTRING( flag_str )->ptr[0] ) {
flags = 1;
}
/* open the blob and associate the db to it */
- rc = sqlite3_blob_open(am_db->db, zDb, zTable, zColumn, iRow, flags, &(am_blob->blob) );
- if ( rc != SQLITE_OK ) {
- rb_raise( eAS_Error, "Error opening Blob in db = %s, table = %s, column = %s, rowid = %ld : [SQLITE_ERROR %d] %s\n",
- zDb, zTable, zColumn, iRow, rc, sqlite3_errmsg( am_db->db ));
+ rc = sqlite3_blob_open( am_db->db, zDb, zTable, zColumn, iRow, flags, &( am_blob->blob ) );
+ if ( SQLITE_OK != rc ) {
+ rb_raise( eAS_Error, "Error opening Blob in db = %s, table = %s, column = %s, rowid = %lu : [SQLITE_ERROR %d] %s\n", zDb, zTable, zColumn, (unsigned long)iRow, rc, sqlite3_errmsg( am_db->db) );
}
am_blob->length = sqlite3_blob_bytes( am_blob->blob );
am_blob->db = am_db->db;
/* if a block is given then yield self and close the blob when done */
@@ -201,12 +200,12 @@
/*
* allocate the am_blob structure
*/
VALUE am_sqlite3_blob_alloc(VALUE klass)
{
- am_sqlite3_blob *wrapper = ALLOC(am_sqlite3_blob);
- VALUE obj = (VALUE)NULL;
+ am_sqlite3_blob *wrapper = ALLOC( am_sqlite3_blob );
+ VALUE obj ;
wrapper->current_offset = 0;
wrapper->db = NULL;
obj = Data_Wrap_Struct(klass, NULL, am_sqlite3_blob_free, wrapper);
return obj;
@@ -214,13 +213,9 @@
void Init_amalgalite3_blob( )
{
- /** :stopdoc:
- * These calls are here just to allow for rdoc generation
- * :startdoc:
- */
VALUE ma = rb_define_module("Amalgalite");
VALUE mas = rb_define_module_under(ma, "SQLite3");
/*
* Encapsulate the SQLite3 Statement handle in a class