ソースを参照

try something

Simon Krajewski 6 年 前
コミット
d004775e9c
1 ファイル変更7 行追加4 行削除
  1. 7 4
      extc/process_stubs.c

+ 7 - 4
extc/process_stubs.c

@@ -23,6 +23,7 @@
  // ported from NekoVM
  // ported from NekoVM
 
 
 #include <caml/alloc.h>
 #include <caml/alloc.h>
+#include <caml/memory.h>
 #include <caml/callback.h>
 #include <caml/callback.h>
 #include <caml/mlvalues.h>
 #include <caml/mlvalues.h>
 #include <caml/fail.h>
 #include <caml/fail.h>
@@ -242,12 +243,13 @@ static void free_process( value vp ) {
 	<doc>
 	<doc>
 	Start a process using a command and the specified arguments.
 	Start a process using a command and the specified arguments.
 	When args is not null, cmd and args will be auto-quoted/escaped.
 	When args is not null, cmd and args will be auto-quoted/escaped.
-	If no auto-quoting/escaping is desired, you should append necessary 
+	If no auto-quoting/escaping is desired, you should append necessary
 	arguments to cmd as if it is inputted to the shell directly, and pass
 	arguments to cmd as if it is inputted to the shell directly, and pass
 	null as args.
 	null as args.
 	</doc>
 	</doc>
 **/
 **/
 CAMLprim value process_run( value cmd, value vargs ) {
 CAMLprim value process_run( value cmd, value vargs ) {
+	CAMLparam2(cmd,vargs);
 	int i, isRaw;
 	int i, isRaw;
 	vprocess *p;
 	vprocess *p;
 	val_check(cmd,string);
 	val_check(cmd,string);
@@ -338,7 +340,7 @@ CAMLprim value process_run( value cmd, value vargs ) {
 		CloseHandle(oread);
 		CloseHandle(oread);
 		CloseHandle(eread);
 		CloseHandle(eread);
 		CloseHandle(iwrite);
 		CloseHandle(iwrite);
-		
+
 		if( !CreateProcess(NULL,val_string(sargs),NULL,NULL,TRUE,0,NULL,NULL,&sinf,&p->pinf) ) {
 		if( !CreateProcess(NULL,val_string(sargs),NULL,NULL,TRUE,0,NULL,NULL,&sinf,&p->pinf) ) {
 			CloseHandle(p->eread);
 			CloseHandle(p->eread);
 			CloseHandle(p->oread);
 			CloseHandle(p->oread);
@@ -405,9 +407,10 @@ CAMLprim value process_run( value cmd, value vargs ) {
 	p->eread = error[0];
 	p->eread = error[0];
 #	endif
 #	endif
 	{
 	{
-		value vp = alloc_abstract(k_process,p);
+		CAMLlocal1(vp);
+		vp = alloc_abstract(k_process,p);
 		val_gc(vp,free_process);
 		val_gc(vp,free_process);
-		return vp;
+		CAMLreturn(vp);
 	}
 	}
 }
 }