Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/lang/LangPrimSource/PyrUnixPrim.cpp b/lang/LangPrimSource/PyrUnixPrim.cpp
- index 769be99..40be03c 100644
- --- a/lang/LangPrimSource/PyrUnixPrim.cpp
- +++ b/lang/LangPrimSource/PyrUnixPrim.cpp
- @@ -115,7 +115,7 @@ struct sc_process {
- bool postOutput;
- };
- -static void string_popen_thread_func(struct sc_process *process)
- +static void string_popen_thread_func(std::unique_ptr<sc_process> process)
- {
- FILE *stream = process->stream;
- pid_t pid = process->pid;
- @@ -134,7 +134,7 @@ static void string_popen_thread_func(struct sc_process *process)
- if(process->postOutput)
- postfl("RESULT = %d\n", res);
- - delete process;
- + //delete process;
- gLangMutex.lock();
- if(compiledOK) {
- @@ -165,7 +165,7 @@ int prString_POpen(struct VMGlobals *g, int numArgsPushed)
- return errNone;
- #endif
- - sc_process *process = new sc_process;
- + std::unique_ptr<sc_process> process(new sc_process);
- process->stream = sc_popen(cmdline, &process->pid, "r");
- setvbuf(process->stream, 0, _IONBF, 0);
- pid_t pid = process->pid;
- @@ -175,11 +175,11 @@ int prString_POpen(struct VMGlobals *g, int numArgsPushed)
- delete [] cmdline;
- if(process->stream == NULL) {
- - delete process;
- + //delete process;
- return errFailed;
- }
- - thread thread(std::bind(string_popen_thread_func, process));
- + thread thread(std::bind(string_popen_thread_func, std::move(process) ));
- thread.detach();
- SetInt(a, pid);
- @@ -237,7 +237,7 @@ int prArrayPOpen(struct VMGlobals *g, int numArgsPushed)
- }
- }
- - sc_process *process = new sc_process;
- + std::unique_ptr<sc_process> process (new sc_process);
- process->stream = sc_popen_argv(filename, argv.data(), &process->pid, "r");
- setvbuf(process->stream, 0, _IONBF, 0);
- pid_t pid = process->pid;
- @@ -245,11 +245,11 @@ int prArrayPOpen(struct VMGlobals *g, int numArgsPushed)
- process->postOutput = IsTrue(b);
- if(process->stream == NULL) {
- - delete process;
- + //delete process;
- return errFailed;
- }
- - thread thread(std::bind(string_popen_thread_func, process));
- + thread thread(std::bind(string_popen_thread_func, std::move(process)));
- thread.detach();
- for (int i=1; i<obj->size; ++i) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement