|
3 | 3 |
|
4 | 4 | #include <sys/types.h> |
5 | 5 | #include <cmath> |
6 | | -#include <cstring> |
| 6 | +#include <string> |
7 | 7 | #include <sqlite3.h> |
8 | 8 | #include <nan.h> |
9 | 9 | #include "strlcpy.h" |
@@ -33,20 +33,18 @@ inline bool IS_32BIT_INT(double num) { |
33 | 33 | return floor(num) == num && num < 2147483648 && num >= -2147483648; |
34 | 34 | } |
35 | 35 |
|
36 | | -// Creates a stack-allocated buffer of the concatenation of 2 well-formed |
| 36 | +// Creates a stack-allocated std:string of the concatenation of 2 well-formed |
37 | 37 | // C-strings. |
38 | 38 | #define CONCAT2(result, a, b) \ |
39 | | - char result[strlen(a) + strlen(b) + 1]; \ |
40 | | - strcpy(result, a); \ |
41 | | - strcat(result, b); |
| 39 | + std::string result(a); \ |
| 40 | + result += b; |
42 | 41 |
|
43 | | -// Creates a stack-allocated buffer of the concatenation of 3 well-formed |
| 42 | +// Creates a stack-allocated std:string of the concatenation of 3 well-formed |
44 | 43 | // C-strings. |
45 | 44 | #define CONCAT3(result, a, b, c) \ |
46 | | - char result[strlen(a) + strlen(b) + strlen(c) + 1]; \ |
47 | | - strcpy(result, a); \ |
48 | | - strcat(result, b); \ |
49 | | - strcat(result, c); |
| 45 | + std::string result(a); \ |
| 46 | + result += b; \ |
| 47 | + result += c; |
50 | 48 |
|
51 | 49 | // Given a v8::Object and a C-string method name, retrieves the v8::Function |
52 | 50 | // representing that method. If the getter throws, or if the property is not a |
@@ -203,7 +201,7 @@ inline bool IS_32BIT_INT(double num) { |
203 | 201 | #define QUERY_THROW_STAY(obj, UNBIND_MACRO, error_out) \ |
204 | 202 | CONCAT2(_error_message, "SQLite: ", error_out); \ |
205 | 203 | QUERY_CLEANUP(obj, UNBIND_MACRO); \ |
206 | | - Nan::ThrowError(_error_message); |
| 204 | + Nan::ThrowError(_error_message.c_str()); |
207 | 205 |
|
208 | 206 | // The macro-instruction that runs after a failed SQLite request. |
209 | 207 | #define QUERY_THROW(obj, UNBIND_MACRO, error_out) \ |
|
0 commit comments