File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 11set_directory_properties (PROPERTIES LABELS malloc)
22
3+ add_executable (c_fortran_malloc main.c)
4+ set_target_properties (c_fortran_malloc PROPERTIES LINKER_LANGUAGE C)
5+ target_link_libraries (c_fortran_malloc PRIVATE vector_fortran)
6+ add_test (NAME C_Fortran_malloc COMMAND c_fortran_malloc)
7+
38add_executable (cxx_fortran_malloc main.cpp)
49target_link_libraries (cxx_fortran_malloc PRIVATE vector_fortran)
510add_test (NAME C++_Fortran_malloc COMMAND cxx_fortran_malloc)
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <stdlib.h>
3+
4+ extern void timestwo (int [], int [], const size_t * );
5+
6+
7+ int main ()
8+ {
9+ const size_t N = 3 ;
10+
11+ int * x = malloc (N * sizeof (int ));
12+ int * x2 = malloc (N * sizeof (int ));
13+
14+ timestwo (& x [0 ], & x2 [0 ], & N );
15+
16+ for (size_t i = 0 ; i < N ; i ++ ){
17+ if (x2 [i ] != 2 * x [i ]){
18+ fprintf (stderr , "value %d != %d\n" , x2 [i ], x [i ]);
19+ return 1 ;
20+ }
21+ }
22+
23+ free (x );
24+ free (x2 );
25+
26+ printf ("OK: C malloc new\n" );
27+
28+ return 0 ;
29+ }
You can’t perform that action at this time.
0 commit comments