Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
8fdc4c8c
Commit
8fdc4c8c
authored
Feb 22, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix memory leaks
parent
72b2667b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
macros.h
src/macros.h
+9
-0
statement.cc
src/statement.cc
+3
-0
statement.h
src/statement.h
+5
-4
No files found.
src/macros.h
View file @
8fdc4c8c
...
@@ -156,5 +156,14 @@ const char* sqlite_code_string(int code);
...
@@ -156,5 +156,14 @@ const char* sqlite_code_string(int code);
stmt->db->Process(); \
stmt->db->Process(); \
delete baton;
delete baton;
#define DELETE_FIELD(field) \
switch ((field)->type) { \
case SQLITE_INTEGER: delete (Data::Integer*)(field); break; \
case SQLITE_FLOAT: delete (Data::Float*)(field); break; \
case SQLITE_TEXT: delete (Data::Text*)(field); break; \
case SQLITE_BLOB: delete (Data::Blob*)(field); break; \
case SQLITE_NULL: delete (Data::Null*)(field); break; \
}
#endif
#endif
src/statement.cc
View file @
8fdc4c8c
...
@@ -552,6 +552,7 @@ int Statement::EIO_AfterAll(eio_req *req) {
...
@@ -552,6 +552,7 @@ int Statement::EIO_AfterAll(eio_req *req) {
Data
::
Rows
::
const_iterator
end
=
baton
->
rows
.
end
();
Data
::
Rows
::
const_iterator
end
=
baton
->
rows
.
end
();
for
(
int
i
=
0
;
it
<
end
;
it
++
,
i
++
)
{
for
(
int
i
=
0
;
it
<
end
;
it
++
,
i
++
)
{
result
->
Set
(
i
,
RowToJS
(
*
it
));
result
->
Set
(
i
,
RowToJS
(
*
it
));
delete
*
it
;
}
}
Local
<
Value
>
argv
[]
=
{
Local
<
Value
>::
New
(
Null
()),
result
};
Local
<
Value
>
argv
[]
=
{
Local
<
Value
>::
New
(
Null
()),
result
};
...
@@ -758,6 +759,8 @@ Local<Array> Statement::RowToJS(Data::Row* row) {
...
@@ -758,6 +759,8 @@ Local<Array> Statement::RowToJS(Data::Row* row) {
result
->
Set
(
i
,
value
);
result
->
Set
(
i
,
value
);
result
->
Set
(
String
::
NewSymbol
(
field
->
name
.
c_str
()),
value
);
result
->
Set
(
String
::
NewSymbol
(
field
->
name
.
c_str
()),
value
);
DELETE_FIELD
(
field
);
}
}
return
result
;
return
result
;
...
...
src/statement.h
View file @
8fdc4c8c
...
@@ -84,15 +84,16 @@ public:
...
@@ -84,15 +84,16 @@ public:
Data
::
Parameters
parameters
;
Data
::
Parameters
parameters
;
Baton
(
Statement
*
stmt_
,
Handle
<
Function
>
cb_
)
:
stmt
(
stmt_
)
{
Baton
(
Statement
*
stmt_
,
Handle
<
Function
>
cb_
)
:
stmt
(
stmt_
)
{
Data
::
Parameters
::
const_iterator
it
=
parameters
.
begin
();
Data
::
Parameters
::
const_iterator
end
=
parameters
.
end
();
for
(;
it
<
end
;
it
++
)
delete
*
it
;
stmt
->
Ref
();
stmt
->
Ref
();
ev_ref
(
EV_DEFAULT_UC
);
ev_ref
(
EV_DEFAULT_UC
);
callback
=
Persistent
<
Function
>::
New
(
cb_
);
callback
=
Persistent
<
Function
>::
New
(
cb_
);
}
}
~
Baton
()
{
~
Baton
()
{
Data
::
Parameters
::
const_iterator
it
=
parameters
.
begin
();
Data
::
Parameters
::
const_iterator
end
=
parameters
.
end
();
for
(;
it
<
end
;
it
++
)
{
DELETE_FIELD
(
*
it
);
}
stmt
->
Unref
();
stmt
->
Unref
();
ev_unref
(
EV_DEFAULT_UC
);
ev_unref
(
EV_DEFAULT_UC
);
callback
.
Dispose
();
callback
.
Dispose
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment