FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add a couple more fixes from julian · nodegit/nodegit@03ce68b · GitHub

Repository navigation

Commit 03ce68b

Browse files
John Alden
committed
add a couple more fixes from julian
1 parent 03b5353 commit 03ce68b

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎generate/templates/manual/include/configurable_class_wrapper.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace nodegit {
4040

4141
virtual ~ConfigurableClassWrapper() {
4242
if (raw != nullptr) {
43-
delete raw;
43+
free(raw);
4444
raw = nullptr;
4545
}
4646
}

‎generate/templates/manual/src/str_array_converter.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ git_strarray *StrArrayConverter::ConstructStrArray(int argc, char** argv) {
6565

6666
void StrArrayConverter::ConvertInto(git_strarray *out, v8::Local<v8::Array> val) {
6767
out->count = val->Length();
68-
out->strings = new char *[out->count];
68+
out->strings = (char**) malloc(out->count * sizeof(char*));
6969
for (uint32_t i = 0; i < out->count; ++i) {
7070
Nan::Utf8String utf8String(Nan::Get(val, i).ToLocalChecked().As<v8::String>());
7171
out->strings[i] = strdup(*utf8String);
@@ -75,6 +75,6 @@ void StrArrayConverter::ConvertInto(git_strarray *out, v8::Local<v8::Array> val)
7575
void StrArrayConverter::ConvertInto(git_strarray *out, v8::Local<v8::String> val) {
7676
Nan::Utf8String utf8String(val);
7777
out->count = 1;
78-
out->strings = new char *[1];
78+
out->strings = (char**) malloc(out->count * sizeof(char*));
7979
out->strings[0] = strdup(*utf8String);
8080
}

‎generate/templates/templates/struct_content.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ Configurable{{ cppClassName }}::Configurable{{ cppClassName }}(nodegit::Context
118118
: nodegit::ConfigurableClassWrapper<{{ cppClassName }}Traits>(nodegitContext)
119119
{
120120
{% if ignoreInit == true %}
121-
this->raw = new {{ cType }};
121+
this->raw = ({{ cType }}*) malloc(sizeof({{ cType }}));
122122
{% else %}
123123
{{ 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 %}));
125125
memcpy(this->raw, &wrappedValue, sizeof({{ cType }}{% if isExtendedStruct %}_extended{% endif %}));
126126
{% endif %}
127127
}
@@ -134,10 +134,10 @@ Configurable{{ cppClassName }}::~Configurable{{ cppClassName }}() {
134134
for (size_t i = 0; i < this->raw->{{ field.name }}.count; ++i) {
135135
free(this->raw->{{ field.name }}.strings[i]);
136136
}
137-
delete[] this->raw->{{ field.name }}.strings;
137+
free(this->raw->{{ field.name }}.strings);
138138
}
139139
{% elsif field.cppClassName == 'String' %}
140-
delete this->raw->{{ field.name }};
140+
free((void*)this->raw->{{ field.name }});
141141
{% endif %}
142142
{% endif %}
143143
{% endeach %}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL