*Confliction if the size changed at the same time.
|
Thread1 |
Thread2 |
dummy_allocation_001 |
touch
|0xFFaaaaa0|
size 8
|
touch
|0xFFaaaaa8|
size 16
|
- |
- |
- |
- |
- |
- |
- |
- |
- |
*
Allocation memorries should be internal in function and return it well for the call of it.
*
Remodification
- |
- |
- |
- |
.\array_counter.cpp File modified time Sat Oct 14 07:04:39 2023
...
0804 char* char_string_012 ( int num_memories ) { 0805 char* dummy_allocation_001_01 = NULL; 0806 printf("char* char_string_012 ( int num_memories ) starts. num_memories=%d dummy_allocation_001_01=%p\r\n", num_memories, dummy_allocation_001_01); 0807 // 20210731 0808 // dummy_allocation_001_01 =NULL; 0809 // print_memories_002(); 0810 for ( int i =0; i<10; i++) { 0811 printf("character i %d/10 num_memories %d about|%p|\r\n", i, num_memories, dummy_allocation_001_01); 0812 dummy_allocation_001_01 = (char*) malloc( sizeof(char) * num_memories ); 0813 printf("dummy_allocation_001_01|%p|\r\n", dummy_allocation_001_01); 0814 if ( dummy_allocation_001_01 != NULL ) { 0815 break; 0816 } 0817 a_sleep_thread (); 0818 } 0819 put_memories_002( dummy_allocation_001_01 ); 0820 printf("char* char_string_012 ( int num_memories ) ends.\r\n"); 0821 return dummy_allocation_001_01; 0822 } 0823 ...
0925 char* copyof_012 ( char* str ) { 0926 int ac; 0927 char* dummy_allocation_001_01 = NULL; 0928 printf("char* copyof_012 ( char* str ) starts.\r\n"); 0929 ac = array_count(str); 0930 printf("array_count %d\r\n", ac ); 0931 dummy_allocation_001_01 = char_string_012 ( ac + 1 ); 0932 a_sleep_thread_002 (); 0933 if ( dummy_allocation_001_01 == NULL ) { 0934 printf("dummy_allocation_001_01 is null.\r\n"); 0935 exit(-1); 0936 } 0937 printf("dummy_allocation_001_01 point|%p|\r\n", dummy_allocation_001_01 ); 0938 put_memories( dummy_allocation_001_01 ); 0939 0940 for ( int i=0; i<ac; i++) { 0941 dummy_allocation_001_01[i] = str[i]; 0942 } 0943 0944 dummy_allocation_001_01[ac] = '\0'; 0945 printf("str |%p| dummy_allocation_001_01 |%p|=|%s|\r\n", str, dummy_allocation_001_01, dummy_allocation_001_01 ); 0946 printf("char* copyof_012 ( char* str ) ends.\r\n"); 0947 return dummy_allocation_001_01; 0948 }
...
|
|
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |