ext/Database.c in rubyfb-0.5.4 vs ext/Database.c in rubyfb-0.5.5
- old
+ new
@@ -193,11 +193,12 @@
*
*/
static VALUE createDatabase(int argc, VALUE *argv, VALUE unused)
{
VALUE database = Qnil,
- set = Qnil;
+ set = Qnil,
+ tmp_str = Qnil;
char sql[512] = "",
*text = NULL;
int value = 1024;
isc_db_handle connection = 0;
isc_tr_handle transaction = 0;
@@ -221,21 +222,24 @@
"2048 4096 or 8192.");
}
}
/* Prepare the SQL statement. */
- sprintf(sql, "CREATE DATABASE '%s'",
- STR2CSTR(rb_funcall(argv[0], rb_intern("to_s"), 0)));
- text = STR2CSTR(rb_funcall(argv[1], rb_intern("to_s"), 0));
+ tmp_str = rb_funcall(argv[0], rb_intern("to_s"), 0);
+ sprintf(sql, "CREATE DATABASE '%s'", StringValuePtr(tmp_str));
+
+ tmp_str = rb_funcall(argv[1], rb_intern("to_s"), 0);
+ text = StringValuePtr(tmp_str);
if(strlen(text) > 0)
{
strcat(sql, " USER '");
strcat(sql, text);
strcat(sql, "'");
}
-
- text = STR2CSTR(rb_funcall(argv[2], rb_intern("to_s"), 0));
+
+ tmp_str = rb_funcall(argv[2], rb_intern("to_s"), 0);
+ text = StringValuePtr(tmp_str);
if(strlen(text) > 0)
{
strcat(sql, " PASSWORD '");
strcat(sql, text);
strcat(sql, "'");
@@ -252,10 +256,10 @@
if(argc > 4 && argv[4] != Qnil)
{
char *text = NULL;
set = rb_funcall(argv[4], rb_intern("to_s"), 0);
- text = STR2CSTR(set);
+ text = StringValuePtr(set);
if(strlen(text) > 0)
{
strcat(sql, " DEFAULT CHARACTER SET ");
strcat(sql, text);
}