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

Updated methods to be shouldAlloc when an allocated buffer is needed · dawnsgithub/nodegit@1cb96b4 · GitHub

Repository navigation

Commit 1cb96b4

Browse files
authored andcommitted
Updated methods to be shouldAlloc when an allocated buffer is needed
1 parent a7f61ee commit 1cb96b4

3 files changed

Lines changed: 83 additions & 23 deletions

File tree

‎generate/input/descriptor.json‎

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@
173173
"out": {
174174
"isReturn": true,
175175
"cppClassName": "GitBuf",
176-
"jsClassName": "Buffer"
176+
"jsClassName": "Buffer",
177+
"shouldAlloc": true
177178
},
178179
"blob": {
179180
"cppClassName": "GitBlob",
@@ -259,7 +260,8 @@
259260
"isReturn": true,
260261
"cppClassName": "GitBuf",
261262
"jsClassName": "Buffer",
262-
"cType": "git_buf *"
263+
"cType": "git_buf *",
264+
"shouldAlloc": true
263265
},
264266
"repo": {
265267
"cppClassName": "GitRepository",
@@ -307,9 +309,9 @@
307309
"jsFunctionName": "grow",
308310
"args": {
309311
"buffer": {
310-
"isReturn": true,
311-
"isSelf": false,
312-
"shouldAlloc": true
312+
"isReturn": false,
313+
"isSelf": true,
314+
"shouldAlloc": false
313315
}
314316
},
315317
"return": {
@@ -324,10 +326,9 @@
324326
"jsFunctionName": "set",
325327
"args": {
326328
"buffer": {
327-
"isReturn": true,
328-
"isSelf": false,
329-
"shouldAlloc": true,
330-
"doNotConvert": true
329+
"isReturn": false,
330+
"isSelf": true,
331+
"shouldAlloc": false
331332
},
332333
"data": {
333334
"cppClassName": "Buffer",
@@ -538,6 +539,19 @@
538539
"return": {
539540
"ownedByThis": true
540541
}
542+
},
543+
"git_commit_header_field": {
544+
"isAsync": true,
545+
"args": {
546+
"out": {
547+
"isReturn": true,
548+
"isSelf": false,
549+
"shouldAlloc": true
550+
}
551+
},
552+
"return": {
553+
"isErrorCode": true
554+
}
541555
}
542556
}
543557
},
@@ -602,6 +616,12 @@
602616
},
603617
"git_config_get_string_buf": {
604618
"isAsync": true,
619+
"args": {
620+
"out": {
621+
"isReturn": true,
622+
"shouldAlloc": true
623+
}
624+
},
605625
"return": {
606626
"isErrorCode": true
607627
}
@@ -674,6 +694,19 @@
674694
"return": {
675695
"isErrorCode": true
676696
}
697+
},
698+
"git_config_find_programdata": {
699+
"isAsync": true,
700+
"return": {
701+
"isErrorCode": true
702+
},
703+
"args": {
704+
"out": {
705+
"isReturn": true,
706+
"isSelf": false,
707+
"shouldAlloc": true
708+
}
709+
}
677710
}
678711
},
679712
"dependencies": [
@@ -883,6 +916,19 @@
883916
"git_diff_status_char": {
884917
"ignore": true
885918
},
919+
"git_diff_to_buf": {
920+
"isAsync": true,
921+
"return": {
922+
"isErrorCode": true
923+
},
924+
"args": {
925+
"out": {
926+
"isReturn": true,
927+
"isSelf": false,
928+
"shouldAlloc": true
929+
}
930+
}
931+
},
886932
"git_diff_tree_to_index": {
887933
"args": {
888934
"old_tree": {
@@ -1969,7 +2015,9 @@
19692015
"isAsync": true,
19702016
"args": {
19712017
"out": {
1972-
"isReturn": true
2018+
"isReturn": true,
2019+
"shouldAlloc": true,
2020+
"isSelf": false
19732021
},
19742022
"remote": {
19752023
"isSelf": true
@@ -2116,6 +2164,13 @@
21162164
"isAsync": true,
21172165
"return": {
21182166
"isErrorCode": true
2167+
},
2168+
"args": {
2169+
"out": {
2170+
"isReturn": true,
2171+
"isSelf": false,
2172+
"shouldAlloc": true
2173+
}
21192174
}
21202175
},
21212176
"git_repository_init_init_options": {
@@ -2479,6 +2534,19 @@
24792534
"isErrorCode": true
24802535
}
24812536
},
2537+
"git_submodule_resolve_url": {
2538+
"isAsync": true,
2539+
"args": {
2540+
"out": {
2541+
"isReturn": true,
2542+
"shouldAlloc": true,
2543+
"isSelf": false
2544+
}
2545+
},
2546+
"return": {
2547+
"isErrorCode": true
2548+
}
2549+
},
24822550
"git_submodule_update": {
24832551
"isAsync": true,
24842552
"args": {

‎generate/templates/partials/async_function.cc‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
1515
{%if arg.globalPayload %}
1616
{{ cppFunctionName }}_globalPayload* globalPayload = new {{ cppFunctionName }}_globalPayload;
1717
{%endif%}
18-
{%if arg.cppClassName == "GitBuf" %}
19-
{%if cppFunctionName == "Set"%}
20-
baton->{{arg.name}} = Nan::ObjectWrap::Unwrap<{{ arg.cppClassName }}>(info.This())->GetValue();
21-
{%else%}
22-
baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
23-
baton->{{arg.name}}->ptr = NULL;
24-
baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0;
25-
{%endif%}
26-
{%endif%}
2718
{%endeach%}
2819

2920
{%each args|argsInfo as arg %}
@@ -61,9 +52,10 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
6152
{%endif%}
6253
{%endif%}
6354
{%elsif arg.shouldAlloc %}
55+
baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
6456
{%if arg.cppClassName == "GitBuf" %}
65-
{%else%}
66-
baton->{{ arg.name }} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }}));
57+
baton->{{arg.name}}->ptr = NULL;
58+
baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0;
6759
{%endif%}
6860
{%endif%}
6961
{%endeach%}

‎test/tests/filter.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ describe("Filter", function() {
405405
var message = "some new fancy filter";
406406
var length = message.length;
407407
var tempBuffer = new Buffer(message, "utf-8");
408-
var largeBufferSize = 300000000;
408+
var largeBufferSize = 500000000;
409409

410410
it("should not apply when check returns GIT_PASSTHROUGH", function(){
411411
var test = this;
@@ -600,7 +600,7 @@ describe("Filter", function() {
600600
})
601601
.then(function() {
602602
var fd = fse.openSync(readmePath, "r");
603-
var readBuf = Buffer.allocUnsafe(300000000);
603+
var readBuf = Buffer.allocUnsafe(largeBufferSize);
604604
var readLength = fse.readSync(
605605
fd,
606606
readBuf,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL