faboussard / 42_minishell

1 stars 0 forks source link

une erreur malloc doit retourner 2 ou -1 ? #62

Closed faboussard closed 4 months ago

melobern commented 5 months ago

12 ENOMEM Out of memory

--> https://www.thegeekstuff.com/2010/10/linux-error-codes/

faboussard commented 5 months ago

dans ce cas il faut quon les revoit car on les a mis soit a -1 soit a 2, ca depend. on les mets tous a 12 ?

void    print_name(t_minishell *m, char *name)
{
    char    *thename;

    thename = ft_strjoin("minishell: ", name);
    if (!thename)
        exit_msg_minishell(m, "Malloc error", -1);
    perror(thename);
    free(thename);
}
melobern commented 5 months ago

Oui, si on peut écrire ENOMEM à chaque fois ce sera encore plus clair et simple à justifier (si ça ne cause pas une ligne trop longue à un moment donné ^^)