| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 03b5353 commit 03ce68b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,7 @@ namespace nodegit { | |||
| 40 | 40 | ||
| 41 | 41 | virtual ~ConfigurableClassWrapper() { | |
| 42 | 42 | if (raw != nullptr) { | |
| 43 | - delete raw; | ||
| 43 | + free(raw); | ||
| 44 | 44 | raw = nullptr; | |
| 45 | 45 | } | |
| 46 | 46 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,7 +65,7 @@ git_strarray *StrArrayConverter::ConstructStrArray(int argc, char** argv) { | |||
| 65 | 65 | ||
| 66 | 66 | void StrArrayConverter::ConvertInto(git_strarray *out, v8::Local<v8::Array> val) { | |
| 67 | 67 | out->count = val->Length(); | |
| 68 | - out->strings = new char *[out->count]; | ||
| 68 | + out->strings = (char**) malloc(out->count * sizeof(char*)); | ||
| 69 | 69 | for (uint32_t i = 0; i < out->count; ++i) { | |
| 70 | 70 | Nan::Utf8String utf8String(Nan::Get(val, i).ToLocalChecked().As<v8::String>()); | |
| 71 | 71 | out->strings[i] = strdup(*utf8String); | |
@@ -75,6 +75,6 @@ void StrArrayConverter::ConvertInto(git_strarray *out, v8::Local<v8::Array> val) | |||
| 75 | 75 | void StrArrayConverter::ConvertInto(git_strarray *out, v8::Local<v8::String> val) { | |
| 76 | 76 | Nan::Utf8String utf8String(val); | |
| 77 | 77 | out->count = 1; | |
| 78 | - out->strings = new char *[1]; | ||
| 78 | + out->strings = (char**) malloc(out->count * sizeof(char*)); | ||
| 79 | 79 | out->strings[0] = strdup(*utf8String); | |
| 80 | 80 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,10 +118,10 @@ Configurable{{ cppClassName }}::Configurable{{ cppClassName }}(nodegit::Context | |||
| 118 | 118 | : nodegit::ConfigurableClassWrapper<{{ cppClassName }}Traits>(nodegitContext) | |
| 119 | 119 | { | |
| 120 | 120 | {% if ignoreInit == true %} | |
| 121 | - this->raw = new {{ cType }}; | ||
| 121 | + this->raw = ({{ cType }}*) malloc(sizeof({{ cType }})); | ||
| 122 | 122 | {% else %} | |
| 123 | 123 | {{ cType }}{% if isExtendedStruct %}_extended{% endif %} wrappedValue = {{ cType|upper }}_INIT; | |
| 124 | - this->raw = ({{ cType }}*) new {{ cType }}{% if isExtendedStruct %}_extended{% endif %}; | ||
| 124 | + this->raw = ({{ cType }}*) malloc(sizeof({{ cType }}{% if isExtendedStruct %}_extended{% endif %})); | ||
| 125 | 125 | memcpy(this->raw, &wrappedValue, sizeof({{ cType }}{% if isExtendedStruct %}_extended{% endif %})); | |
| 126 | 126 | {% endif %} | |
| 127 | 127 | } | |
@@ -134,10 +134,10 @@ Configurable{{ cppClassName }}::~Configurable{{ cppClassName }}() { | |||
| 134 | 134 | for (size_t i = 0; i < this->raw->{{ field.name }}.count; ++i) { | |
| 135 | 135 | free(this->raw->{{ field.name }}.strings[i]); | |
| 136 | 136 | } | |
| 137 | - delete[] this->raw->{{ field.name }}.strings; | ||
| 137 | + free(this->raw->{{ field.name }}.strings); | ||
| 138 | 138 | } | |
| 139 | 139 | {% elsif field.cppClassName == 'String' %} | |
| 140 | - delete this->raw->{{ field.name }}; | ||
| 140 | + free((void*)this->raw->{{ field.name }}); | ||
| 141 | 141 | {% endif %} | |
| 142 | 142 | {% endif %} | |
| 143 | 143 | {% endeach %} | |
| Back | FazBrowse Home | New Git URL |
0 commit comments