开发者

openmp pointers question

开发者 https://www.devze.com 2023-02-23 07:01 出处:网络
I have written a program in C which needs to be parallelised using openmp. I have declared the private and shared variables but in the beginning of the code when I am calling some procedures to fr开发

I have written a program in C which needs to be parallelised using openmp. I have declared the private and shared variables but in the beginning of the code when I am calling some procedures to fr开发者_Go百科ee up the lists I get

error for object 0x1000c1e20: pointer being freed was not allocated

      destroy_t_value(head_t1_values);
      t_value_delete(&head_t1_values, 0);
      destroy_chi_value(head_chi1_values);
      chi_value_delete(&head_chi1_values, 0);

These variables are private The code works fine without openmp


That is the problem: "Before entering the parallel part they are allocated and set to NULL"

You cannot allocate a pointer, then set it to NULL and then free it, cause now you are freeing a pointer that points to nothing.

You need to allocate, then use them, then deallocate (ie delete) and then set to NULL.

0

精彩评论

暂无评论...
验证码 换一张
取 消