--- rpl/src/gestion_objets.c 2018/12/21 10:56:16 1.139 +++ rpl/src/gestion_objets.c 2020/01/10 11:15:42 1.148 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.29 - Copyright (C) 1989-2018 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.32 + Copyright (C) 1989-2020 Dr. BERTRAND Joël This file is part of RPL/2. @@ -635,7 +635,7 @@ allocation(struct_processus *s_etat_proc } else { - if (((*s_objet).objet = malloc(2 * sizeof(struct_objet *))) + if (((*s_objet).objet = malloc(sizeof(struct_record))) == NULL) { (*s_etat_processus).erreur_systeme = @@ -1317,7 +1317,7 @@ liberation(struct_processus *s_etat_proc } else { - free((real8 *) ((*s_objet).objet)); + free((struct_record *) ((*s_objet).objet)); } break; @@ -2484,6 +2484,46 @@ copie_objet(struct_processus *s_etat_pro break; } + case REC : + { + if (type != 'P') + { + if ((s_nouvel_objet = allocation(s_etat_processus, REC)) + == NULL) + { + return(NULL); + } + + if (((*((struct_record *) (*s_nouvel_objet).objet)).noms = + copie_objet(s_etat_processus, (*((struct_record *) + (*s_objet).objet)).noms, 'P')) == NULL) + { + return(NULL); + } + + if (((*((struct_record *) (*s_nouvel_objet).objet)).donnees = + copie_objet(s_etat_processus, (*((struct_record *) + (*s_objet).objet)).donnees, type)) == NULL) + { + return(NULL); + } + } + else + { + incrementation_atomique(s_objet); + (*((struct_record *) (*s_objet).objet)).noms = + copie_objet(s_etat_processus, (*((struct_record *) + (*s_objet).objet)).noms, 'P'); + (*((struct_record *) (*s_objet).objet)).donnees = + copie_objet(s_etat_processus, (*((struct_record *) + (*s_objet).objet)).donnees, 'P'); + + return(s_objet); + } + + break; + } + case REL : { if (type != 'O') @@ -3034,8 +3074,33 @@ copie_etat_processus(struct_processus *s return(NULL); } + + if (pthread_mutex_lock(&((*s_etat_processus).mutex_interruptions)) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return(NULL); + } + + if (pthread_mutex_lock(&((*s_etat_processus).mutex_signaux)) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return(NULL); + } + (*s_nouvel_etat_processus) = (*s_etat_processus); + if (pthread_mutex_unlock(&((*s_etat_processus).mutex_signaux)) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return(NULL); + } + + if (pthread_mutex_unlock(&((*s_etat_processus).mutex_interruptions)) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return(NULL); + } + // On réinitialise les allocateurs. pthread_mutexattr_init(&attributs_mutex); @@ -3901,6 +3966,13 @@ debug_memoire_ajout(size_t taille, const sizeof(unsigned char))) == NULL) { pthread_mutex_unlock(&mutex_allocation); + + uprintf("[%d-%llu] ILLEGAL POINTER (malloc) $%016X\n", + getpid(), (unsigned long long) pthread_self(), NULL); +# ifdef __BACKTRACE + BACKTRACE(PROFONDEUR_PILE); +# endif + return(NULL); } @@ -3961,8 +4033,9 @@ debug_memoire_modification(void *pointeu { pthread_mutex_unlock(&mutex_allocation); - uprintf("[%d-%llu] ILLEGAL POINTER (realloc)\n", - getpid(), (unsigned long long) pthread_self()); + uprintf("[%d-%llu] ILLEGAL POINTER (realloc) $%016X\n", + getpid(), (unsigned long long) pthread_self(), + pointeur); # ifdef __BACKTRACE BACKTRACE(PROFONDEUR_PILE); # endif @@ -4058,8 +4131,8 @@ debug_memoire_retrait(void *pointeur) if (element_courant == NULL) { - uprintf("[%d-%llu] ILLEGAL POINTER (free)\n", - getpid(), (unsigned long long) pthread_self()); + uprintf("[%d-%llu] ILLEGAL POINTER (free) $%016X\n", + getpid(), (unsigned long long) pthread_self(), pointeur); # ifdef __BACKTRACE BACKTRACE(PROFONDEUR_PILE); # endif @@ -4176,7 +4249,7 @@ debug_memoire_verification() } pid_t -debug_fork() +debug_fork(struct_processus *s_etat_processus) { pid_t pid;