Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. diff --git a/lang/LangPrimSource/PyrUnixPrim.cpp b/lang/LangPrimSource/PyrUnixPrim.cpp
  2. index 769be99..40be03c 100644
  3. --- a/lang/LangPrimSource/PyrUnixPrim.cpp
  4. +++ b/lang/LangPrimSource/PyrUnixPrim.cpp
  5. @@ -115,7 +115,7 @@ struct sc_process {
  6. bool postOutput;
  7. };
  8.  
  9. -static void string_popen_thread_func(struct sc_process *process)
  10. +static void string_popen_thread_func(std::unique_ptr<sc_process> process)
  11. {
  12. FILE *stream = process->stream;
  13. pid_t pid = process->pid;
  14. @@ -134,7 +134,7 @@ static void string_popen_thread_func(struct sc_process *process)
  15. if(process->postOutput)
  16. postfl("RESULT = %d\n", res);
  17.  
  18. - delete process;
  19. + //delete process;
  20.  
  21. gLangMutex.lock();
  22. if(compiledOK) {
  23. @@ -165,7 +165,7 @@ int prString_POpen(struct VMGlobals *g, int numArgsPushed)
  24. return errNone;
  25. #endif
  26.  
  27. - sc_process *process = new sc_process;
  28. + std::unique_ptr<sc_process> process(new sc_process);
  29. process->stream = sc_popen(cmdline, &process->pid, "r");
  30. setvbuf(process->stream, 0, _IONBF, 0);
  31. pid_t pid = process->pid;
  32. @@ -175,11 +175,11 @@ int prString_POpen(struct VMGlobals *g, int numArgsPushed)
  33. delete [] cmdline;
  34.  
  35. if(process->stream == NULL) {
  36. - delete process;
  37. + //delete process;
  38. return errFailed;
  39. }
  40.  
  41. - thread thread(std::bind(string_popen_thread_func, process));
  42. + thread thread(std::bind(string_popen_thread_func, std::move(process) ));
  43. thread.detach();
  44.  
  45. SetInt(a, pid);
  46. @@ -237,7 +237,7 @@ int prArrayPOpen(struct VMGlobals *g, int numArgsPushed)
  47. }
  48. }
  49.  
  50. - sc_process *process = new sc_process;
  51. + std::unique_ptr<sc_process> process (new sc_process);
  52. process->stream = sc_popen_argv(filename, argv.data(), &process->pid, "r");
  53. setvbuf(process->stream, 0, _IONBF, 0);
  54. pid_t pid = process->pid;
  55. @@ -245,11 +245,11 @@ int prArrayPOpen(struct VMGlobals *g, int numArgsPushed)
  56. process->postOutput = IsTrue(b);
  57.  
  58. if(process->stream == NULL) {
  59. - delete process;
  60. + //delete process;
  61. return errFailed;
  62. }
  63.  
  64. - thread thread(std::bind(string_popen_thread_func, process));
  65. + thread thread(std::bind(string_popen_thread_func, std::move(process)));
  66. thread.detach();
  67.  
  68. for (int i=1; i<obj->size; ++i) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement