Waitrud Weber’s blog

things and reminders for memories

3d: windows-make: jackson structured programming

We settled on the code sets
on the blelow:

Lots of code:

1. bruch_functions_all
2. initialize_parameter();

 

model of cad drawing

1. Circle 
2. Parabora parametric
3. Scale of models


*

- - - -
- - - -
-

.\jackson_animation_focus_003.cpp  File modified time Wed Jan 03 23:24:52 2024

0001 #include <stdlib.h>
0002 #include <stdio.h>
0003 
0004 #include <windows.h>
0005 
0006 struct struct_animation_focus {
0007     int start_x;
0008     int start_y;
0009     int width;
0010     int height;
0011 };
0012 
0013 struct struct_animation_focus_frame {
0014     void* draw_number;
0015     void* draw_effects;
0016     void* draw_model_frame;
0017     void* draw_grid;
0018     void* initialize_parameters_all;
0019     int **canvas;
0020     int thread_sleep_real_animation = 33;
0021     int thread_animation_times = 60;
0022     int initialized = 0;
0023     struct_animation_focus focus;
0024 };
0025 
0026 typedef struct_animation_focus_frame ANIMATION_FOCUS_FRAME;
0027 typedef struct_animation_focus_frame ANIMATION_FOCUS;
0028 
0029 ANIMATION_FOCUS_FRAME *p_jackson;
0030 ANIMATION_FOCUS_FRAME m_jackson;
0031 
0032 
0033 int call_draw_fucus_canvas_buffer_only () ;
0034 int call_draw_canvas_all ();
0035 DWORD WINAPI Animation_5times_thread_canvas_focus_validate ( LPVOID hdc ) ;
0036 
0037 void* draw_number ();
0038 void* draw_effects ();
0039 void* draw_model_frame ();
0040 void* draw_grid ();
0041 void* initialize_parameters_all () ;
0042 
0043 int bruch_functions_all ();
0044 
0045 //
0046 int bruch_functions_all () {
0047     p_jackson = &m_jackson;
0048     p_jackson->draw_number = (void*)draw_number;
0049     p_jackson->draw_effects =(void*) draw_effects;
0050     p_jackson->draw_model_frame = (void*)draw_model_frame;
0051     p_jackson->draw_grid = (void*)draw_grid;
0052 
0053     p_jackson->initialize_parameters_all= (void*)initialize_parameters_all;
0054 
0055     return 0;
0056 }
0057 
0058 //
0059 void* initialize_parameters_all () {
0060     int i, j;
0061 
0062     for ( i= p_jackson->focus.start_x; i<p_jackson->focus.width; i++ ) {
0063         p_jackson->canvas[i] = (int*)malloc (sizeof(int) + p_jackson->focus.height);
0064         if ( p_jackson->canvas[i] == NULL ) {
0065             printf("p_jackson->canvas[%d]", i );
0066             exit(-1);
0067         }
0068     }
0069 
0070 
0071     for ( j= p_jackson->focus.start_y; j<p_jackson->focus.height; j++ )
0072     for ( i= p_jackson->focus.start_x; i<p_jackson->focus.width; i++ ) {
0073         p_jackson->canvas[i][j] = 0;;
0074     }
0075 
0076     p_jackson->thread_sleep_real_animation = 33;
0077     p_jackson->thread_animation_times = 60;
0078 //    return (void*);
0079 }
0080 
0081 void* draw_number () {
0082 //    return (void*);
0083 }
0084 
0085 void* draw_effects () {
0086 //    return (void*);
0087 }
0088 
0089 void* draw_model_frame () {
0090 //    return (void*);
0091 }
0092 
0093 void* draw_grid () {
0094 //    return (void*);
0095 }
0096 
0097 
0098 //
0099 // Draw to focus canvas buffer only
0100 int call_draw_fucus_canvas_buffer_only () {
0101     int a;
0102     static int model_changed = 0;
0103 
0104     model_changed = 1;
0105     model_changed = model_changed  % 4 + 1;
0106 
0107     switch ( model_changed ) {
0108     case 0:
0109         break;
0110     case 1:
0111         p_jackson->draw_number;
0112         break;
0113     case 2:
0114         p_jackson->draw_effects;
0115         break;
0116     case 3:
0117         p_jackson->draw_model_frame;
0118         break;
0119     case 4:
0120         p_jackson->draw_grid;
0121         break;
0122     }
0123 
0124     return 0;
0125 }
0126 
0127 
0128 //
0129 //
0130 //
0131 int call_draw_canvas_all () {
0132     int i, j;
0133 
0134     for ( j= p_jackson->focus.start_y; j<p_jackson->focus.height; j++ )
0135     for ( i= p_jackson->focus.start_x; i<p_jackson->focus.width; i++ ) {
0136         p_jackson->canvas[i][j];
0137     }
0138 
0139     return 0;
0140 }
0141 
0142 //
0143 //
0144 //
0145 DWORD WINAPI Animation_5times_thread_canvas_focus_validate ( LPVOID hdc ) {
0146     int i, a;
0147 
0148     if ( p_jackson->initialized != 1 ) {
0149         p_jackson->initialize_parameters_all; 
0150         p_jackson->initialized = 1;
0151     }
0152 
0153     //            
0154     for ( i = 0; i<p_jackson->thread_animation_times; i++ ) {
0155         a = call_draw_fucus_canvas_buffer_only ();
0156         a = call_draw_canvas_all ();
0157         Sleep (p_jackson->thread_sleep_real_animation);
0158     }
0159 }
0160 
0161 
0162 

- -
-

*
In file jackson_animation_focus_003.cpp.txt line 0073 and double semi-colon:
In file winmainthread_005a_000.cpp, there is no includion "image_layer_001.h":
In file winmainthread_005a_003.cpp, there is no includion "image_layer_001.h":
*
But they were compiled well.
And, text file changed after their compilation.

Error:

 

Memories Allocation:
We could allocate the image buffers at the date of 20240110.

 

- -
- - - -




CodeAnalyzer: windows-make: 2

To Reduce any confliction as parameters, we use Lock-On as param.

That control should be functions of process head and taile usually with curly-brace '{' and `]`.

*scope

- - - -
-
int file_read_lock_on () {
if ( f_file_read_lock_on == 1 ) {
message  = csvcopyof( (char*)"is unreadable already." );
return 0;
f_file_read_lock_on = 1;
message  = csvcopyof( (char*)"is unreadable any." );
return 1;
}
 
int file_read_lock_off () {
if ( f_file_read_lock_on != 0 ) {
f_file_read_lock_on = 0;
message  = csvcopyof( (char*)"is readable any." );
}
return 1;
}
 
char* get_message () {
return message;
}
 
- -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -

*

... is well.

 

*

- - - -
-

CodeAnalyzer: html: The way you are. - Waitrud Weber’s blog

- -
-

CodeAnalyzer: windows-make: html: - Waitrud Weber’s blog

- -
- - - -
- - - -
- - - -
- - - -
- - - -

 

*

CodeAnalyzer: windows-make: 1

*
Find index of functions as name in *.cpp.

To avoid friction of compilation error and that execution, we define the message type and consider the scope of codes.

For example, on the code of loop, the message as "printf" could be read worse more.

*

- - - -
-

    success = 0;
    key_j = 0;
    for ( i=0; i< end_index; i++ ) {
        c = get_char(fp);
        token_str = (char*) put_token (c);
        for ( j = 0; j<N; j++ ) {
            success = (char*)m_last_with ( token_str, (char*) func_return [j] );
            if (success == 1) {
                key_j = j;
                break;
            } 
        }
    }

- -
- Lock_On - -
- Lock_Out - -
- Type List.  - -
- - - -
- - - -
- - - -

 

*

-   type  -
1 function  - -
2 out of loop mem -
3 - - -
4 - - -
5 - - -
6 - - -
7 - - -

 

*dependency

- - ensure -
1 printf value and code -
2 sprintf value and code -
- - - -
- - - -
- - - -
- - - -
- - - -

*

The code value as calculation is ensured some times only when we use the "printf".

 

windows-make: Memorization:

At the least,for the ensure of memorries work, We care of it, that is on short scope as function. And, our mistakes are going to be reduced.

*

- width height
char*** o -
char** - o
char* - -
- - -
- - -
- - -

*source code

- - -
-

read_csv_000a_014.cpp  File modified time Fri Oct 13 14:52:17 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "log_001.h"
0015 
0016 #include "read_csv_000a_014.h"
0017 
0018 char logmsg[255];
0019 static Logging* log_001;
0020 static LOG_001* dlog_001 = NULL;
0021 
0022 extern char* filename_read_csv_000a_014_ = (char*)"read_csv_000a_014.txt";
0023 
0024 int read_csv_000a_014 ();
0025 int set_read_csv_000a_014 (char** argv, int argc);
0026 int initialize_read_csv_000a_014 (char** argv, int argc);
0027 
0028 int print_log_result_003 (char*** result) ;
0029 int print_log_result_002 (char** result) ;
0030 int print_log_result_001 (char* result) ;
0031 char***    realloc_char_003_01 ( char*** restr, int num ) ;
0032 char**    realloc_char_002_01 ( char** restr, int num ) ;
0033 char***    malloc_char_003_01 ( int num ) ;
0034 char**    malloc_char_002_01 ( int num ) ;
0035 
0036 int memories_height ( int width, int height, char*** mem ) ;
0037 int memories_width ( int from_w_i, int width, int height, char*** mem ) ;
0038 
0039 
0040 int memories_width ( int from_w_i, int width, int height, char*** mem ) {
0041 
0042     int i, j;
0043 
0044     mem = (char***) realloc_char_003_01 ( mem, width );
0045     for ( i = from_w_i; i<width; i++ ) {
0046         mem[i] = (char**) realloc_char_002_01  ( mem[i], height );
0047         print_log_result_002 ( mem[i] );
0048         for ( j=0; j<height; j++ ) {
0049             mem[i][j] = copyof_012 ( "-" );
0050             print_log_result_001 ( mem[i][j] );
0051         }
0052     }
0053 
0054     print_log_result_003 (mem);
0055 }
0056 
0057 int memories_height ( int width, int height, char*** mem ) {
0058 
0059     int i,j;
0060 
0061     mem = (char***) realloc_char_003_01 ( mem, width );
0062     for ( i = 0; i<width; i++ ) {
0063         mem[i] = (char**) realloc_char_002_01  ( mem[i], height );
0064         print_log_result_002 ( mem[i] );
0065         for ( j=0; j<height; j++ ) {
0066             print_log_result_001 ( mem[i][j] );
0067         }
0068     }
0069 
0070     print_log_result_003 (mem);
0071 }
0072 
0073 //
0074 char***    malloc_char_003_01 ( int num ) {
0075     char*** result;
0076 
0077     result = (char***)malloc ( sizeof (char**) * num ) ;
0078     if (result == NULL ) {
0079         dlog_001 = log_001->update_log ( (char*)"We cannot allocate the result.");
0080         exit(-1);
0081     }
0082 
0083     print_log_result_003 ((char***)result);
0084     return result;
0085 }
0086 
0087 //
0088 char**    malloc_char_002_01 ( int num ) {
0089     char** result;
0090 
0091     result = (char**)malloc ( sizeof (char*) * num ) ;
0092     if (result == NULL ) {
0093         dlog_001 = log_001->update_log ( (char*)"We cannot allocate the result.");
0094         exit(-1);
0095     }
0096 
0097     print_log_result_002 ((char**)result);
0098     return result;
0099 }
0100 
0101 //
0102 char***    realloc_char_003_01 ( char*** restr, int num ) {
0103     char*** result;
0104 
0105     result = (char***)realloc ( restr, sizeof (char**) * num ) ;
0106     if (result == NULL ) {
0107         dlog_001 = log_001->update_log ( (char*)"We cannot allocate the result.");
0108         exit(-1);
0109     }
0110 
0111     print_log_result_003 ((char***)result);
0112     return result;
0113 }
0114 
0115 //
0116 char**    realloc_char_002_01 ( char** restr, int num ) {
0117     char** result;
0118 
0119     result = (char**)realloc ( restr, sizeof (char*) * num ) ;
0120     if (result == NULL ) {
0121         dlog_001 = log_001->update_log ( (char*)"We cannot allocate the result.");
0122         exit(-1);
0123     }
0124 
0125     print_log_result_002 ((char**)result);
0126     return result;
0127 }
0128 
0129 
0130 int print_log_result_003 (char*** result) {
0131     sprintf( logmsg, "result|%p|", (char***)result );
0132     dlog_001 = log_001->update_log ( (char*)logmsg);
0133     return 0;
0134 }
0135 
0136 int print_log_result_002 (char** result) {
0137     sprintf( logmsg, "result|%p|", (char**)result );
0138     dlog_001 = log_001->update_log ( (char*)logmsg);
0139     return 0;
0140 }
0141 
0142 int print_log_result_001 (char* result) {
0143     sprintf( logmsg, "result|%p|", (char*)result );
0144     dlog_001 = log_001->update_log ( (char*)logmsg);
0145     return 0;
0146 }
0147 
0148 
0149 
0150 int read_csv_000a_014 () {
0151     return 1;
0152 
0153 }
0154 
0155 
0156 int read_csv_000a_set_014 (char** argv, int argc) {
0157      return 1;
0158  
0159 }
0160 
0161 int read_csv_000a_initialize_014 (char** argv, int argc) {
0162      return 1;
0163  
0164 }
0165 
0166 

-
- - -
- - -
- - -
- - -
- - -

3d: windows-make: Memorization:

*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 }

...

  - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -

 

windows-make: csv: CSV frame ... 005

Logging is set each patch, which is actually seperated file *.c and is going to be compiled.

*

- - - - -
         
  i 14 void Initialize_firstset_004 () ends.
i 15 int file_all_size ( char* filename, int *file_end ) starts.
i 16 msg 001-filename-20230621.txt file_end |00499260| 404
i 17 int file_all_size ( char* filename, int *file_end ) ends.
i 18 int csv_once_002 (int *index, int *end_index ) starts.
i 19 SEEK index_r |0|
i 20 msg dummy |"| c|34|
i 21 count 1 word_002 |"| word_002_c |"| c|34|
i 22 SEEK index_r |1|
i 23 msg dummy |-| c|45|
i 24 count 2 word_002 |"-| word_002_c |"-| c|45|
i 25 SEEK index_r |2|
i 26 msg dummy |"| c|34|
i 27 count 3 word_002 |"-"| word_002_c |"-"| c|34|
i 28 SEEK index_r |3|
i 29 msg dummy |,| c|44|
i 30 count 4 word_002 |"-",| word_002_c |"-",| c|44|
i 31 SEEK index_r |4|
i 32 msg dummy |"| c|34|
i 33 count 5 word_002 |"-","| word_002_c |"-","| c|34|
i 34 SEEK index_r |5|
i 35 msg dummy |-| c|45|
i 36 count 6 word_002 |"-","-| word_002_c |"-","-| c|45|
i 37 SEEK index_r |6|
i 38 msg dummy |"| c|34|
i 39 count 7 word_002 |"-","-"| word_002_c |"-","-"| c|34|
i 40 SEEK index_r |7|
i 41 msg dummy |,| c|44|
i 42 count 8 word_002 |"-","-",| word_002_c |"-","-",| c|44|
i 43 SEEK index_r |8|
i 44 msg dummy |"| c|34|
i 45 count 9 word_002 |"-","-","| word_002_c |"-","-","| c|34|
i 46 SEEK index_r |9|
i 47 msg dummy |-| c|45|
i 48 count 10 word_002 |"-","-","-| word_002_c |"-","-","-| c|45|
i 49 int csv_once_002 (int *index, int *end_index ) ends.
i 50 print_log :
LOG_001* Logging::print_log () ends.
     
  And, there is a remaining quote part of solution in csv.      
 

i 30 int csv_once_002 (int *index, int *end_index ) starts.
i 31 SEEK index_r |0|
i 32 msg dummy |"| c|34|
i 33 count 1 word_002 |"| word_002_c |"| c|34|
i 34 SEEK index_r |1|
i 35 msg dummy |-| c|45|
i 36 count 2 word_002 |"-| word_002_c |"-| c|45|
i 37 SEEK index_r |2|
i 38 msg dummy |"| c|34|
i 39 count 3 word_002 |"-"| word_002_c |"-"| c|34|
i 40 SEEK index_r |3|
i 41 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 42 msg 1 0 grid matrix g
i 43 msg 1 0 word "-"
i 44 int puttheword_004 ( int ii, int jj, char* word ) end.
i 45 SEEK index_r |4|
i 46 msg dummy |"| c|34|
i 47 count 5 word_002 |"| word_002_c |"| c|34|
i 48 SEEK index_r |5|
i 49 msg dummy |-| c|45|
i 50 count 6 word_002 |"-| word_002_c |"-| c|45|
i 51 SEEK index_r |6|
i 52 msg dummy |"| c|34|
i 53 count 7 word_002 |"-"| word_002_c |"-"| c|34|
i 54 SEEK index_r |7|
i 55 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 56 msg 2 0 grid matrix g
i 57 msg 2 0 word "-"
i 58 int puttheword_004 ( int ii, int jj, char* word ) end.
i 59 SEEK index_r |8|
i 60 msg dummy |"| c|34|
i 61 count 9 word_002 |"| word_002_c |"| c|34|
i 62 SEEK index_r |9|
i 63 msg dummy |-| c|45|
i 64 count 10 word_002 |"-| word_002_c |"-| c|45|
i 65 int csv_once_002 (int *index, int *end_index ) ends.
i 66 print_log :
LOG_001* Logging::print_log () ends.

     

windows-make: csv: CSV frame ... 004

Memory allocation is like the Matrix like Lotus and Excel.
Function realloc and malloc work well, which is a beautiful work in C language.

*

- - - - -
 

read_csv_004.cpp  File modified time Sun Aug 06 22:32:51 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "read_csv_004.h"
0015 
0016 GRID_MATRIX_004* grid_matrix_004 = NULL;
0017 
0018 int puttheword_004 ( int ii, int jj, char* word ) ;
0019 int    initialize_grid_matrix_004 () ;
0020 
0021 //
0022 int puttheword_004 ( int ii, int jj, char* word ) {
0023     int a, i, rmode, ri;
0024 
0025     if ( grid_matrix_004 == NULL ) {
0026         a = initialize_grid_matrix_004 ();
0027     }
0028 
0029     rmode = 0;
0030     if (grid_matrix_004->width_index_num_max <= ii ) {
0031         rmode = 1;
0032         ri = grid_matrix_004->width_index_num_max;
0033         for ( i= 0; ii < grid_matrix_004->width_index_num_max; i++ ) {
0034             grid_matrix_004->width_index_num_max *= 2;
0035         }
0036         grid_matrix_004->grid_matrix = (char***)realloc ( grid_matrix_004->grid_matrix , sizeof(char**) * grid_matrix_004->width_index_num_max );
0037         for ( i = ri; i< grid_matrix_004->height_index_num_max; i++ ) {
0038             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0039         }
0040     }
0041 
0042     if (grid_matrix_004->height_index_num_max <jj ) {
0043         rmode = 2;
0044         for ( i= 0; jj < grid_matrix_004->height_index_num_max; i++ ) {
0045             grid_matrix_004->height_index_num_max *= 2;
0046         }
0047         for ( i = 0; i< grid_matrix_004->height_index_num_max; i++ ) {
0048             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0049         }
0050     }
0051 
0052     aFree(grid_matrix_004->grid_matrix[ii][jj]);
0053     grid_matrix_004->grid_matrix[ii][jj] = (char*) copyof ( word );
0054 
0055     return 0;
0056 }
0057 
0058 
0059 //
0060 int    initialize_grid_matrix_004 () {
0061     int i, j;
0062 
0063     grid_matrix_004 = (GRID_MATRIX_004*) malloc ( sizeof (GRID_MATRIX_004) );
0064     if ( grid_matrix_004 == NULL ) {
0065         exit(-1);
0066     }
0067 
0068     grid_matrix_004->grid_matrix = (char***)malloc ( sizeof(char**) * grid_matrix_004->width_index_num_max );
0069     for ( i = 0; i< grid_matrix_004->width_index_num_max; i++ ) {
0070         grid_matrix_004->grid_matrix[i] = (char**)malloc ( sizeof(char*) * grid_matrix_004->height_index_num_max );
0071         if ( grid_matrix_004->grid_matrix[i] == NULL ) {
0072             exit(-1);
0073         }
0074         for ( j = 0; j< grid_matrix_004->height_index_num_max; j++ ) {
0075             grid_matrix_004->grid_matrix[i][j] = (char*)copyof("g");
0076         }
0077     }
0078 
0079     return  0;
0080 }
0081 

     
 

.\read_csv_004.h  File modified time Mon Aug 07 16:48:05 2023

0001 #ifndef _SETTLE_GRID_004_H_
0002 #define _SETTLE_GRID_004_H_
0003 
0004 typedef struct grid_matrix_struct_004 {
0005     int width_index = 0;
0006     int width_index_num = 0;
0007     int width_index_num_max = 8;
0008     int height_index = 0;
0009     int height_index_num = 0;
0010     int height_index_num_max = 8;
0011     char***    grid_matrix = NULL;
0012 } GRID_MATRIX_004;
0013 
0014 extern int puttheword_004 ( int ii, int jj, char* word ) ;
0015 extern int filesize_004( FILE *fp ) ;
0016 extern int file_all_size ( char* filename, int *file_end ) ;
0017 extern int Set_Logging_read_csv_004 ( Logging* log ) ;
0018 
0019 #endif
0020 

     
 

Frrst arrays should be set as initialization and 8 and 8 in 2 demention but it was not settled, and so, the execution was failed and modified. Allocation is sized only and doesn't ensure any set of intialization with malloc.

 

.\read_csv_004.cpp  File modified time Mon Aug 07 17:44:03 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "log_001.h"
0015 
0016 #include "read_csv_004.h"
0017 
0018 GRID_MATRIX_004* grid_matrix_004 = NULL;
0019 
0020 static Logging* log_001;
0021 static LOG_001* dlog_001 = NULL;
0022 
...
0082 //
0083 int    initialize_grid_matrix_004 () {
0084     int i, j;
0085     char msg[255];
0086 
0087     dlog_001 = log_001->update_log ( (char*)"int    initialize_grid_matrix_004 () starts." );
0088 
0089     grid_matrix_004 = (GRID_MATRIX_004*) malloc ( sizeof (GRID_MATRIX_004) );
0090     if ( grid_matrix_004 == NULL ) {
0091         exit(-1);
0092     }
0093 
0094     grid_matrix_004->width_index_num_max = 8;
0095     grid_matrix_004->height_index_num_max = 8;
0096 
0097     grid_matrix_004->grid_matrix = (char***)malloc ( sizeof(char**) * grid_matrix_004->width_index_num_max );
0098 
0099     sprintf( msg, "grid_matrix_004->grid_matrix |%p| grid_matrix_004->width_index_num_max=%d", grid_matrix_004->grid_matrix, grid_matrix_004->width_index_num_max );
0100     dlog_001 = log_001->update_log ( (char*) msg );
0101 
0102     sprintf( msg, "grid_matrix_004->grid_matrix |%p| grid_matrix_004->height_index_num_max=%d", grid_matrix_004->grid_matrix, grid_matrix_004->height_index_num_max );
0103     dlog_001 = log_001->update_log ( (char*) msg );
0104 
0105     for ( i = 0; i< grid_matrix_004->width_index_num_max; i++ ) {
0106         grid_matrix_004->grid_matrix[i] = (char**)malloc ( sizeof(char*) * grid_matrix_004->height_index_num_max );
0107         if ( grid_matrix_004->grid_matrix[i] == NULL ) {
0108             exit(-1);
0109         }
0110         for ( j = 0; j< grid_matrix_004->height_index_num_max; j++ ) {
0111             grid_matrix_004->grid_matrix[i][j] = (char*)copyof("g");
0112         }
0113     }
0114 
0115     dlog_001 = log_001->update_log ( (char*)"int    initialize_grid_matrix_004 () ends." );
0116     return  0;
0117 }
0118 
0119 
0120 //
0121 int file_all_size ( char* filename, int *file_end ) {
0122     FILE *fp;
0123     char msg[255];
0124 
0125     dlog_001 = log_001->update_log ( (char*)"int file_all_size ( char* filename, int *file_end ) starts." );
0126 
0127     fp = fopen ( filename, "rb" );
0128     *file_end = filesize_004 ( fp );
0129 
0130     fclose(fp);
0131 
0132     sprintf( msg, "msg %s file_end |%p| %d", filename, file_end, *file_end );
0133 
0134     dlog_001 = log_001->update_log ( (char*) msg );
0135 
0136     dlog_001 = log_001->update_log ( (char*)"int file_all_size ( char* filename, int *file_end ) ends." );
0137 }
0138 
0139 //
0140 int filesize_004( FILE *fp ) {
0141 
0142     fseek(fp, 0L, SEEK_END);
0143     int sz = ftell(fp);
0144 
0145     fseek(fp, 0L, SEEK_SET);
0146 
0147     return sz;
0148 }
0149 
0150 //
0151 int Set_Logging_read_csv_004 ( Logging* log ) {
0152     log_001 = (Logging*)log;
0153     return 0;
0154 }
0155 
0156 
0157 

     
 

i 9 void Initialize_firstset_004 () starts.
i 10 1
i 11 2
i 12 3
i 13 4
i 14 void Initialize_firstset_004 () ends.
i 15 int file_all_size ( char* filename, int *file_end ) starts.
i 16 msg 001-filename-20230621.txt file_end |00499260| 404
i 17 int file_all_size ( char* filename, int *file_end ) ends.
i 18 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 19 int    initialize_grid_matrix_004 () starts.
i 20 grid_matrix_004->grid_matrix |025406A8| grid_matrix_004->width_index_num_max=8
i 21 grid_matrix_004->grid_matrix |025406A8| grid_matrix_004->height_index_num_max=8
i 22 int    initialize_grid_matrix_004 () ends.
i 23 msg 1 1 grid matrix g

i 24 msg 1 1 word aaa

i 25 int puttheword_004 ( int ii, int jj, char* word ) end.
i 26 print_log :
LOG_001* Logging::print_log () ends.

     
  .\read_csv_004.cpp  File modified time Wed Aug 09 17:09:54 2023
...
0032 int puttheword_004 ( int ii, int jj, char* word ) {
0033     int a, i, rmode, ri;
0034     char msg[255];
0035 
0036     dlog_001 = log_001->update_log ( (char*)"int puttheword_004 ( int ii, int jj, char* word ) starts." );
0037 
0038     if ( grid_matrix_004 == NULL ) {
0039         a = initialize_grid_matrix_004 ();
0040     }
0041 
0042     rmode = 0;
0043     if (grid_matrix_004->width_index_num_max <= ii ) {
0044         rmode = 1;
0045         ri = grid_matrix_004->width_index_num_max;
0046         for ( i= 0; ii >= grid_matrix_004->width_index_num_max; i++ ) {
0047             grid_matrix_004->width_index_num_max *= 2;
0048         }
0049         printf("out i %d jj %d width_index_num_max %d\r\n", i, jj, grid_matrix_004->width_index_num_max );
0050         grid_matrix_004->grid_matrix = (char***)realloc ( grid_matrix_004->grid_matrix , sizeof(char**) * grid_matrix_004->width_index_num_max );
0051         for ( i = ri; i< grid_matrix_004->height_index_num_max; i++ ) {
0052             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0053         }
0054     }
0055 
0056     if (grid_matrix_004->height_index_num_max <=jj ) {
0057         rmode = 2;
0058         printf("in i %d jj %d height_index_num_max %d\r\n", i, jj, grid_matrix_004->height_index_num_max );
0059         for ( i= 0; jj >= grid_matrix_004->height_index_num_max; i++ ) {
0060             printf("i %d jj %d height_index_num_max %d\r\n", i, jj, grid_matrix_004->height_index_num_max );
0061             grid_matrix_004->height_index_num_max *= 2;
0062         }
0063         printf("out i %d jj %d height_index_num_max %d\r\n", i, jj, grid_matrix_004->height_index_num_max );
0064         for ( i = 0; i< grid_matrix_004->height_index_num_max; i++ ) {
0065             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0066         }
0067     }
0068 
0069     sprintf( msg, "msg %d %d grid matrix %s", ii, jj, (char*) grid_matrix_004->grid_matrix[ii][jj]  );
0070     dlog_001 = log_001->update_log ( (char*) msg );
0071 
0072     aFree(grid_matrix_004->grid_matrix[ii][jj]);
0073     grid_matrix_004->grid_matrix[ii][jj] = (char*) copyof ( word );
0074 
0075 
0076     sprintf( msg, "msg %d %d word %s", ii, jj, word  );
0077     dlog_001 = log_001->update_log ( (char*) msg );
0078 
0079     dlog_001 = log_001->update_log ( (char*)"int puttheword_004 ( int ii, int jj, char* word ) end." );
0080 
0081     return 0;
0082 }
     
  i 14  ii, int jj, char* word ) end.
i 15 int file_all_size ( char* filename, int *file_end ) starts.
i 16 msg 001-filename-20230621.txt file_end |0049A260| 404
i 17 int file_all_size ( char* filename, int *file_end ) ends.
i 18 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 19 int    initialize_grid_matrix_004 () starts.
i 20 grid_matrix_004->grid_matrix |0099CDC8| grid_matrix_004->width_index_num_max=8
i 21 grid_matrix_004->grid_matrix |0099CDC8| grid_matrix_004->height_index_num_max=8
i 22 int    initialize_grid_matrix_004 () ends.
i 23 msg 1 1 grid matrix g
i 24 msg 1 1 word aaa
i 25 int puttheword_004 ( int ii, int jj, char* word ) end.
i 26 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 27 msg 8 8 grid matrix (null)
i 28 msg 8 8 word bbb
i 29 int puttheword_004 ( int ii, int jj, char* word ) end.
     
         
         


*