Commit 1cb96b49 authored by Carson Howard's avatar Carson Howard Committed by unknown

Updated methods to be shouldAlloc when an allocated buffer is needed

parent a7f61ee1
......@@ -173,7 +173,8 @@
"out": {
"isReturn": true,
"cppClassName": "GitBuf",
"jsClassName": "Buffer"
"jsClassName": "Buffer",
"shouldAlloc": true
},
"blob": {
"cppClassName": "GitBlob",
......@@ -259,7 +260,8 @@
"isReturn": true,
"cppClassName": "GitBuf",
"jsClassName": "Buffer",
"cType": "git_buf *"
"cType": "git_buf *",
"shouldAlloc": true
},
"repo": {
"cppClassName": "GitRepository",
......@@ -307,9 +309,9 @@
"jsFunctionName": "grow",
"args": {
"buffer": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
"isReturn": false,
"isSelf": true,
"shouldAlloc": false
}
},
"return": {
......@@ -324,10 +326,9 @@
"jsFunctionName": "set",
"args": {
"buffer": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true,
"doNotConvert": true
"isReturn": false,
"isSelf": true,
"shouldAlloc": false
},
"data": {
"cppClassName": "Buffer",
......@@ -538,6 +539,19 @@
"return": {
"ownedByThis": true
}
},
"git_commit_header_field": {
"isAsync": true,
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
},
"return": {
"isErrorCode": true
}
}
}
},
......@@ -602,6 +616,12 @@
},
"git_config_get_string_buf": {
"isAsync": true,
"args": {
"out": {
"isReturn": true,
"shouldAlloc": true
}
},
"return": {
"isErrorCode": true
}
......@@ -674,6 +694,19 @@
"return": {
"isErrorCode": true
}
},
"git_config_find_programdata": {
"isAsync": true,
"return": {
"isErrorCode": true
},
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
}
}
},
"dependencies": [
......@@ -883,6 +916,19 @@
"git_diff_status_char": {
"ignore": true
},
"git_diff_to_buf": {
"isAsync": true,
"return": {
"isErrorCode": true
},
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
}
},
"git_diff_tree_to_index": {
"args": {
"old_tree": {
......@@ -1969,7 +2015,9 @@
"isAsync": true,
"args": {
"out": {
"isReturn": true
"isReturn": true,
"shouldAlloc": true,
"isSelf": false
},
"remote": {
"isSelf": true
......@@ -2116,6 +2164,13 @@
"isAsync": true,
"return": {
"isErrorCode": true
},
"args": {
"out": {
"isReturn": true,
"isSelf": false,
"shouldAlloc": true
}
}
},
"git_repository_init_init_options": {
......@@ -2479,6 +2534,19 @@
"isErrorCode": true
}
},
"git_submodule_resolve_url": {
"isAsync": true,
"args": {
"out": {
"isReturn": true,
"shouldAlloc": true,
"isSelf": false
}
},
"return": {
"isErrorCode": true
}
},
"git_submodule_update": {
"isAsync": true,
"args": {
......
......@@ -15,15 +15,6 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
{%if arg.globalPayload %}
{{ cppFunctionName }}_globalPayload* globalPayload = new {{ cppFunctionName }}_globalPayload;
{%endif%}
{%if arg.cppClassName == "GitBuf" %}
{%if cppFunctionName == "Set"%}
baton->{{arg.name}} = Nan::ObjectWrap::Unwrap<{{ arg.cppClassName }}>(info.This())->GetValue();
{%else%}
baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
baton->{{arg.name}}->ptr = NULL;
baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0;
{%endif%}
{%endif%}
{%endeach%}
{%each args|argsInfo as arg %}
......@@ -61,9 +52,10 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
{%endif%}
{%endif%}
{%elsif arg.shouldAlloc %}
baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
{%if arg.cppClassName == "GitBuf" %}
{%else%}
baton->{{ arg.name }} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
baton->{{arg.name}}->ptr = NULL;
baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0;
{%endif%}
{%endif%}
{%endeach%}
......
......@@ -405,7 +405,7 @@ describe("Filter", function() {
var message = "some new fancy filter";
var length = message.length;
var tempBuffer = new Buffer(message, "utf-8");
var largeBufferSize = 300000000;
var largeBufferSize = 500000000;
it("should not apply when check returns GIT_PASSTHROUGH", function(){
var test = this;
......@@ -600,7 +600,7 @@ describe("Filter", function() {
})
.then(function() {
var fd = fse.openSync(readmePath, "r");
var readBuf = Buffer.allocUnsafe(300000000);
var readBuf = Buffer.allocUnsafe(largeBufferSize);
var readLength = fse.readSync(
fd,
readBuf,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment