I have an ANSI C program in Linux CentOS 64-bit computer containing the following lines:
H1_real = malloc(len_SPURFREQ_TIE * sizeof(double)); /* allocate memory */
H1_imag = malloc(len_SPURFREQ_TIE * sizeof(double)); /* allocate memory */
H2_real = malloc(len_SPURFREQ_TIE * sizeof(double)); /* allocate memory */
H2_imag = malloc(len_SPURFREQ_TIE * sizeof(double)); /* allocate memory */
H3_real = malloc(len_SPURFREQ_TIE * sizeof(double)); /* allocate memory */
H3_imag = malloc(len_SPURFREQ_TIE * sizeof(double)); /* allocate memory */
if ( (H1_real == NULL) || (H1_imag == NULL) || (H2_real == NULL) || (H2_imag == NULL) || (H3_real == NULL) || (H3_imag = NULL) ) {
exit(6);
}
When I use gdb to check the allocated addresses of H1_real to H3_imag, they look fine. The if statement also executes fine, in that exit(6) is not triggered. But when checking the H3_imag address after the if statement executes, it now read 0x0. Anyone know what could be going on?
is supposed to be: