Skip to content
This repository
Browse code

[SQlite] use explicit memory management for strings. arnsholt++

  • Loading branch information...
commit 9b339432405228a895c76bf1193bdba3f935b99b 1 parent a5f4ae0
Moritz Lenz authored May 02, 2012

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. 9  lib/DBDish/SQLite.pm6
9  lib/DBDish/SQLite.pm6
@@ -88,6 +88,7 @@ class DBDish::SQLite::StatementHandle does DBDish::StatementHandle {
88 88
     has $!statement_handle;
89 89
     has $.dbh;
90 90
     has Int $!row_status;
  91
+    has @!mem_rows;
91 92
 
92 93
     method !handle-error($status) {
93 94
         return if $status == SQLITE_OK;
@@ -106,13 +107,21 @@ class DBDish::SQLite::StatementHandle does DBDish::StatementHandle {
106 107
                 CArray[OpaquePointer]
107 108
         );
108 109
         $!statement_handle = @stmt[0];
  110
+        note "prepare: $!statement_handle.WHICH() text: $!statement";
109 111
         self!handle-error($status);
110 112
     }
111 113
 
112 114
     method execute(*@params) {
113 115
         sqlite3_reset($!statement_handle) if $!statement_handle.defined;
  116
+        @!mem_rows = ();
  117
+        my @strings;
114 118
         for @params.kv -> $idx, $v {
  119
+            if $v ~~ Str {
  120
+                explicitly-manage($v);
  121
+                @!mem_rows.push: $v;
  122
+            }
115 123
             self!handle-error(sqlite3_bind($!statement_handle, $idx + 1, $v));
  124
+            push @strings, $v;
116 125
         }
117 126
         $!row_status = sqlite3_step($!statement_handle);
118 127
         self.rows;

0 notes on commit 9b33943

Please sign in to comment.
Something went wrong with that request. Please try again.