Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing pointer to array of pointers as parameter
    primarykey
    data
    text
    <p>I have the following problem, the following function is called with conflict initialised to NULL. </p> <p>At the end of foo, conflict takes the correct values. In the case of this example, *conflict should contain the values 4, 8 and 2. Which it does, according to the fprintfs.</p> <p>However, when I test again in the function calling foo (see second code excerpt), the conflict array hasn't been modified. I'm not sure why, since I'm passing a pointer to the array, especially since this technique works well for the multiDB and recursive pointers. Any help would be appreciated. (this is not the full code by the way, I've only shown the relevant parts). Thanks!</p> <pre><code>int foo( /*==================*/ uchar* buf, uint* multiDB, uint* recursive, uint** conflict) { select_consistent= conflict; bool finished; if (((start_of_scan == 1) &amp;&amp; (*multiDB != 1)) || ((start_of_scan== 0) &amp;&amp; (select_consistent == NULL))) { fprintf(stderr, "Not doing select consistent \n "); finished = TRUE; } else { *multiDB=0; fprintf(stderr, "Doing select consistent \n "); finished = FALSE; uint n; int i = 0 ; if (select_consistent == NULL) { /*This is the first round */ next_round = FALSE; fp = popen("./algorithm '[t(1,[t(2,||),t(3,[t(8,||),t(10,||)])]).t(1,[t(4,||),t(6,||)]).t(1,[t(2,||),t(7,||)])]'", "r"); /* Issue the command. */ finished = FALSE; } if (next_round == TRUE ) { goto parse_records; } fscanf(fp, "%lu", &amp;n); uint* conflict_ ; if (n!=0) conflict_ = (uint*) malloc(sizeof (uint) * n); conflict = &amp;conflict_; next_round = TRUE; int j= 0 ; while (fscanf(fp, "%lu", &amp;n) != EOF) { if (n == 0) { select_consistent=conflict; goto parse_records; } else { (*conflict)[j] = n; } i++; j++; } finished = TRUE; } parse_records:; int error; .... [other code] foo2(multiDB, recursive); fprintf(stderr, "Array states %lu %lu \n ", (*conflict)[0], (*conflict)[1]); fprintf(stderr, "Array states %lu %lu \n ", (*select_consistent)[0], (*select_consistent)[1]); return error } </code></pre> <p>The function calling foo does it like this:</p> <pre><code> uint** conflict = NULL ; error = foo(buf, multiDB, recursive, conflict); fprintf(stderr, "value is %lu \n", (*conflict)[0]); //This is still unitialised. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload