@@ -36,7 +36,7 @@ int CeedCheckFilePath(Ceed ceed, const char *source_file_path, bool *is_valid) {
3636
3737 ierr = CeedCalloc (source_file_path_length , & source_file_path_only );
3838 CeedChk (ierr );
39- strncpy (source_file_path_only , source_file_path , source_file_path_length - 1 );
39+ memcpy (source_file_path_only , source_file_path , source_file_path_length - 1 );
4040 } else {
4141 source_file_path_only = (char * )source_file_path ;
4242 }
@@ -123,7 +123,7 @@ static inline int CeedLoadSourceToInitalizedBuffer(Ceed ceed,
123123 const char * next_e = strchr (first_hash , 'e' );
124124 char keyword [8 ] = "" ;
125125 if (next_e )
126- strncpy (keyword , & next_e [-6 ], 7 );
126+ memcpy (keyword , & next_e [-6 ], 7 );
127127 bool is_hash_include = !strcmp (keyword , "include" );
128128 // ---- Spaces allowed in '# include <header.h>'
129129 if (next_e )
@@ -134,9 +134,9 @@ static inline int CeedLoadSourceToInitalizedBuffer(Ceed ceed,
134134 long current_size = strlen (* buffer );
135135 long copy_size = first_hash - & temp_buffer [file_offset ];
136136 ierr = CeedRealloc (current_size + copy_size + 2 , buffer ); CeedChk (ierr );
137- strncpy (& (* buffer )[current_size ], "\n" , 2 );
138- strncpy (& (* buffer )[current_size + 1 ], & temp_buffer [file_offset ], copy_size );
139- strncpy (& (* buffer )[current_size + copy_size ], "" , 1 );
137+ memcpy (& (* buffer )[current_size ], "\n" , 2 );
138+ memcpy (& (* buffer )[current_size + 1 ], & temp_buffer [file_offset ], copy_size );
139+ memcpy (& (* buffer )[current_size + copy_size ], "" , 1 );
140140 // -- Load local "header.h"
141141 char * next_quote = strchr (first_hash , '"' );
142142 char * next_new_line = strchr (first_hash , '\n' );
@@ -149,10 +149,10 @@ static inline int CeedLoadSourceToInitalizedBuffer(Ceed ceed,
149149 long include_file_name_len = strchr (& next_quote [1 ], '"' ) - next_quote - 1 ;
150150 ierr = CeedCalloc (root_length + include_file_name_len + 2 ,
151151 & include_source_path ); CeedChk (ierr );
152- strncpy (include_source_path , source_file_path , root_length + 1 );
153- strncpy (& include_source_path [root_length + 1 ], & next_quote [1 ],
154- include_file_name_len );
155- strncpy (& include_source_path [root_length + include_file_name_len + 1 ], "" , 1 );
152+ memcpy (include_source_path , source_file_path , root_length + 1 );
153+ memcpy (& include_source_path [root_length + 1 ], & next_quote [1 ],
154+ include_file_name_len );
155+ memcpy (& include_source_path [root_length + include_file_name_len + 1 ], "" , 1 );
156156 // ---- Recursive call to load source to buffer
157157 ierr = CeedLoadSourceToInitalizedBuffer (ceed , include_source_path , buffer );
158158 CeedDebug256 (ceed , 2 , "JiT Including: %s\n" , include_source_path );
@@ -168,9 +168,9 @@ static inline int CeedLoadSourceToInitalizedBuffer(Ceed ceed,
168168 long current_size = strlen (* buffer );
169169 long copy_size = strlen (& temp_buffer [file_offset ]);
170170 ierr = CeedRealloc (current_size + copy_size + 2 , buffer ); CeedChk (ierr );
171- strncpy (& (* buffer )[current_size ], "\n" , 2 );
172- strncpy (& (* buffer )[current_size + 1 ], & temp_buffer [file_offset ], copy_size );
173- strncpy (& (* buffer )[current_size + copy_size + 1 ], "" , 1 );
171+ memcpy (& (* buffer )[current_size ], "\n" , 2 );
172+ memcpy (& (* buffer )[current_size + 1 ], & temp_buffer [file_offset ], copy_size );
173+ memcpy (& (* buffer )[current_size + copy_size + 1 ], "" , 1 );
174174
175175 // Cleanup
176176 ierr = CeedFree (& temp_buffer ); CeedChk (ierr );
@@ -235,8 +235,8 @@ int CeedPathConcatenate(Ceed ceed, const char *base_file_path,
235235 new_file_path_length = base_length + relative_length + 1 ;
236236
237237 ierr = CeedCalloc (new_file_path_length , new_file_path ); CeedChk (ierr );
238- strncpy (* new_file_path , base_file_path , base_length );
239- strncpy (& ((* new_file_path )[base_length ]), relative_file_path , relative_length );
238+ memcpy (* new_file_path , base_file_path , base_length );
239+ memcpy (& ((* new_file_path )[base_length ]), relative_file_path , relative_length );
240240
241241 return CEED_ERROR_SUCCESS ;
242242}
0 commit comments