Tu n'es pas assez attentif.
env2->buffer = malloc(4096 * sizeof(char*));
cd = malloc(my_strlen(env2->buffer) * sizeof(char*));
cd1 = malloc(my_strlen(env2->buffer) * sizeof(char*));
tmp...
Type: Messages; Utilisateur: diogene
Tu n'es pas assez attentif.
env2->buffer = malloc(4096 * sizeof(char*));
cd = malloc(my_strlen(env2->buffer) * sizeof(char*));
cd1 = malloc(my_strlen(env2->buffer) * sizeof(char*));
tmp...
i = 0;
patate = malloc((my_strlen(tab1[i]) + my_strlen(buffer) + 1) * sizeof(char));
Ceci n'alloue la quantité de mémoire correcte que pour le traitement de tab1[0]
patate[0] = '\0';
...
Dans init(), même défaut que tu ne sembles pas comprendre :
tab = malloc((cpt_word(env2->s1, ':') + 1) * sizeof(*tab));
tab = my_str_to_wordtab(*my_getenv("PATH", env2->environ), ':');
On ne...
init() ne sert pas à rien puisqu'il initialise env2. C'est uniquement un problème d'allocation de tabl : Qui la fait, init() ou my_str_to_wordtab() ? Il faut choisir.
Pour le sizeof, c'est ici...
Je veux bien, mais la ligne qui suit init() détruit l'adresse renvoyée par init().
tab1 = init(env2);
tab1 = my_str_to_wordtab(*my_getenv("PATH", env2->environ), ':');
J'ai bien compris,...
patate = malloc((my_strlen(tab1[i]) + my_strlen(buffer) + 1) * sizeof(char*));
if (patate == NULL)
my_putstr_error("errreur amlloc");
strcat(patate, *tab1);
- Tu ne peux pas...
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.