Click here to Skip to main content
15,891,745 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Has C++ ever considered XML style namespaces? Pin
CPallini3-May-19 0:05
mveCPallini3-May-19 0:05 
GeneralRe: Has C++ ever considered XML style namespaces? Pin
Stefan_Lang3-May-19 3:58
Stefan_Lang3-May-19 3:58 
GeneralRe: Has C++ ever considered XML style namespaces? Pin
CPallini3-May-19 4:23
mveCPallini3-May-19 4:23 
GeneralRe: Has C++ ever considered XML style namespaces? Pin
Victor Nijegorodov3-May-19 4:54
Victor Nijegorodov3-May-19 4:54 
GeneralRe: Has C++ ever considered XML style namespaces? Pin
CPallini3-May-19 5:15
mveCPallini3-May-19 5:15 
GeneralRe: Has C++ ever considered XML style namespaces? Pin
Victor Nijegorodov3-May-19 8:11
Victor Nijegorodov3-May-19 8:11 
GeneralRe: Has C++ ever considered XML style namespaces? Pin
Stefan_Lang6-May-19 4:41
Stefan_Lang6-May-19 4:41 
QuestionMFC Top Level menu position. Pin
Maximilien29-Apr-19 7:50
Maximilien29-Apr-19 7:50 
AnswerRe: MFC Top Level menu position. Pin
leon de boer1-May-19 0:13
leon de boer1-May-19 0:13 
QuestionImage display problem in listcontrol Pin
tianzhili439925-Apr-19 16:50
tianzhili439925-Apr-19 16:50 
AnswerRe: Image display problem in listcontrol Pin
Victor Nijegorodov25-Apr-19 21:07
Victor Nijegorodov25-Apr-19 21:07 
GeneralRe: Image display problem in listcontrol Pin
tianzhili439925-Apr-19 22:29
tianzhili439925-Apr-19 22:29 
GeneralRe: Image display problem in listcontrol Pin
Victor Nijegorodov26-Apr-19 2:03
Victor Nijegorodov26-Apr-19 2:03 
QuestionConversion from- C++ to C-language < free(): invalid size > Pin
zak10025-Apr-19 9:14
zak10025-Apr-19 9:14 
AnswerRe: Conversion from- C++ to C-language < free(): invalid size > Pin
k505425-Apr-19 10:05
mvek505425-Apr-19 10:05 
AnswerRe: Conversion from- C++ to C-language < free(): invalid size > Pin
John R. Shaw26-Apr-19 9:19
John R. Shaw26-Apr-19 9:19 
GeneralRe: Conversion from- C++ to C-language < free(): invalid size > Pin
zak10026-Apr-19 10:22
zak10026-Apr-19 10:22 
GeneralRe: Conversion from- C++ to C-language < free(): invalid size > Pin
John R. Shaw26-Apr-19 12:31
John R. Shaw26-Apr-19 12:31 
It looks like you may be accessing a null pointer location - that is just a guess based on the line "Failing at address: (nil)".

Also, given that the first argument failure calls MPI_Finalize() before returning. You should be calling it before returning from anywhere in the main function - consistancy is important.

The following is still and issue
file_buffer = (double *) malloc(num_rows * sizeof(double *));//1
should be
file_buffer = (double *) malloc(num_rows * sizeof(double));//1
because you are storing double values, not pointer values. That also applies to your other buffers, with the exception of of the data buffer. The data buffer is a pointer to an memory allocated array of pointers. Although the individual entries in the array should be allocated like so
data[i] = malloc(num_rows * sizeof(double); /* not sizeof(double *)
You may want to consider using calloc, when allocating the data array, to ensure that all the pointer variables are initialized to 0.
data = (double **)calloc(num_rows, sizeof(double*));
The main reason you want all pointer types initialized to null (a.k.a. 0), is that free function ignores null pointers. But if the pointer contains some random value, then the behavior is undefined and anything could happen - compiler dependent behavior.

What may help you better understand what is happening; you could always add a print statement everywhere you allocate or modify the data. This is what you would call old school debugging - the print statements are removed before releasing the finished product.

Example:
printf("data (double**)calloc(%d, sizeof(double*)", num_col);
OR
printf("data (double**)calloc(%d, %u)", num_col, sizeof(double *));
For very small data sets, doing this in the data allocation loop will also be helpfull.
for(int i=0; i < num_cols; ++i)
{
    printf("data[%d] = malloc(%u)", i, num_rows * sizeof(double));
    data[i] = (double*) malloc(num_rows * sizeof(double));
    if (data[i] == NULL)
    {
       // print error
       // clean up
       return -2;
    }
}


If you run the program from the command line, then you can just pipe the output to a file for latter study.
application.exe >> output.txt
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone

GeneralRe: Conversion from- C++ to C-language < free(): invalid size > Pin
zak10026-Apr-19 14:57
zak10026-Apr-19 14:57 
GeneralRe: Conversion from- C++ to C-language < free(): invalid size > Pin
zak10026-Apr-19 17:53
zak10026-Apr-19 17:53 
GeneralRe: Conversion from- C++ to C-language < free(): invalid size > Pin
John R. Shaw30-Apr-19 4:56
John R. Shaw30-Apr-19 4:56 
GeneralRe: Conversion from- C++ to C-language < free(): invalid size > Pin
zak10030-Apr-19 5:48
zak10030-Apr-19 5:48 
QuestionPointer to Pointer: Conversion from- C++ to C-language Pin
zak10024-Apr-19 18:47
zak10024-Apr-19 18:47 
AnswerRe: Pointer to Pointer: Conversion from- C++ to C-language Pin
Victor Nijegorodov24-Apr-19 20:41
Victor Nijegorodov24-Apr-19 20:41 
GeneralRe: Pointer to Pointer: Conversion from- C++ to C-language Pin
leon de boer25-Apr-19 2:09
leon de boer25-Apr-19 2:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.