From 7913efdfdc3838b0acc07f7fd21d6d32e84d832a Mon Sep 17 00:00:00 2001 From: Sam Krew Date: Tue, 17 Feb 2015 00:32:11 +0300 Subject: [PATCH] Fixed build for node 0.12 --- src/util.cc | 14 +++++++------- src/util.h | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/util.cc b/src/util.cc index 06585dc..6619801 100644 --- a/src/util.cc +++ b/src/util.cc @@ -3,13 +3,13 @@ #include char *get(v8::Handle value, const char *fallback) { + NanScope(); + char *str; if (value->IsString()) { - v8::String::AsciiValue string(value); - char *str = (char *) malloc(string.length() + 1); - strcpy(str, *string); - return str; - } - char *str = (char *) malloc(strlen(fallback) + 1); - strcpy(str, fallback); + NanUtf8String string(value); + str = strdup(*string); + } else { + str = strdup(fallback); + } return str; } \ No newline at end of file diff --git a/src/util.h b/src/util.h index 252ed47..6837b0f 100644 --- a/src/util.h +++ b/src/util.h @@ -3,6 +3,7 @@ #include #include +#include char *get(v8::Handle value, const char *fallback = "");