X-Git-Url: https://git.piment-noir.org/?p=TD_C.git;a=blobdiff_plain;f=TP_13%2Fexo1%2Flib%2Farray.c;h=d2e6182808f6dea9fa87ff335d02771d6782c58f;hp=f7e324f662e21e73bb86c8bcc1850d9ae36b1b72;hb=34dd19e9551e120279afde8d75a1cb51181d7794;hpb=34f864c6720b5e480db66430a218e2fd54743ce7 diff --git a/TP_13/exo1/lib/array.c b/TP_13/exo1/lib/array.c index f7e324f..d2e6182 100644 --- a/TP_13/exo1/lib/array.c +++ b/TP_13/exo1/lib/array.c @@ -4,15 +4,13 @@ int* create_tab(int tab[], unsigned tab_size) { tab = malloc(sizeof(int) * tab_size); - if (tab == NULL) { - return NULL; - } else { + if (tab != NULL) { /* initialize to zero the integer array */ for (unsigned i = 0; i < tab_size; i++) { tab[i] = 0; } - return tab; } + return tab; } void free_tab(int tab[]) { @@ -38,11 +36,7 @@ int* concat_tab(int tab1[], unsigned tab_size1, int tab2[], unsigned tab_size2, int* resize_tab(int tab[], unsigned new_tab_size) { tab = realloc(tab, sizeof(int) * new_tab_size); - if (tab == NULL) { - return NULL; - } else { - return tab; - } + return tab; } /* number of occurences of an element in an unsorted array */