environ #15

Merged
cromer merged 27 commits from environ into master 2021-07-17 22:15:24 -04:00
2 changed files with 3 additions and 3 deletions
Showing only changes of commit b9b6d60aff - Show all commits

View File

@ -62,7 +62,7 @@ void insert_string_array(StringArray *string_array, char *string) {
*/ */
void delete_string_array(StringArray *string_array, int index) { void delete_string_array(StringArray *string_array, int index) {
if (string_array->array != NULL && string_array->size > 0 && string_array->size > index) { if (string_array->array != NULL && string_array->size > 0 && string_array->size > index) {
for (int i = index; i < string_array->size - 1; i++) { for (size_t i = index; i < string_array->size - 1; i++) {
free(string_array->array[i]); free(string_array->array[i]);
string_array->array[i] = NULL; string_array->array[i] = NULL;
string_array->array[i] = malloc(sizeof(string_array->array[i + 1])); string_array->array[i] = malloc(sizeof(string_array->array[i + 1]));
@ -99,7 +99,7 @@ void free_string_array(StringArray *string_array) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
else { else {
for (int i = 0; i < string_array->size; i++) { for (size_t i = 0; i < string_array->size; i++) {
if (string_array->array[i] != NULL) { if (string_array->array[i] != NULL) {
free(string_array->array[i]); free(string_array->array[i]);
string_array->array[i] = NULL; string_array->array[i] = NULL;

View File

@ -32,7 +32,7 @@ void launch_program(StringArray *args) {
if (child == 0) { if (child == 0) {
// Copy the array and add a NULL to the end of it // Copy the array and add a NULL to the end of it
char *argv[args->size + 1]; char *argv[args->size + 1];
for (int i = 0; i < args->size; i++) { for (size_t i = 0; i < args->size; i++) {
argv[i] = args->array[i]; argv[i] = args->array[i];
} }
argv[args->size] = NULL; argv[args->size] = NULL;