--- rpl/src/formateur.c 2010/01/27 22:22:10 1.2 +++ rpl/src/formateur.c 2010/01/29 16:49:23 1.3 @@ -104,19 +104,12 @@ formateur(struct_processus *s_etat_proce -------------------------------------------------------------------------------- */ - sprintf(tampon, "%016lX", (*((unsigned long *) ((*s_objet).objet)))); - - chaine = (unsigned char *) malloc((strlen(tampon) + 3) - * sizeof(unsigned char)); - - if (chaine == NULL) + if (alsprintf(&chaine, "@ %016lX", (*((unsigned long *) + ((*s_objet).objet)))) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - - strcpy(chaine, "@ "); - strcat(chaine, tampon); } else if ((*s_objet).type == SLB) { @@ -127,34 +120,14 @@ formateur(struct_processus *s_etat_proce -------------------------------------------------------------------------------- */ - sprintf(tampon, " %016lX", (unsigned long) (*((struct_bibliotheque *) - (*s_objet).objet)).descripteur); - - chaine = (unsigned char *) malloc((strlen(tampon) + 10) - * sizeof(unsigned char)); - - if (chaine == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return(NULL); - } - - strcpy(chaine, "Library $"); - strcat(chaine, tampon); - - registre = chaine; - - if ((chaine = malloc((strlen(registre) + 2 + - strlen((*(struct_bibliotheque *) ((*s_objet).objet)).nom) - + 2) * sizeof(unsigned char))) == NULL) + if (alsprintf(&chaine, "Library $ %016lX [%s]", + (unsigned long) (*((struct_bibliotheque *) + (*s_objet).objet)).descripteur, (*((struct_bibliotheque *) + (*s_objet).objet)).nom) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - - sprintf(chaine, "%s [%s]", registre, (*((struct_bibliotheque *) - (*s_objet).objet)).nom); - free(registre); } else if ((*s_objet).type == SPH) { @@ -165,21 +138,13 @@ formateur(struct_processus *s_etat_proce -------------------------------------------------------------------------------- */ - sprintf(tampon, "%016lX", (unsigned long) - &((*((struct_semaphore *) (*s_objet).objet)).semaphore)); - - chaine = (unsigned char *) malloc((strlen(tampon) + 15 + - strlen((*((struct_semaphore *) (*s_objet).objet)).nom)) - * sizeof(unsigned char)); - - if (chaine == NULL) + if (alsprintf(&chaine, "Semaphore $ %016lX '%s'", + &((*((struct_semaphore *) (*s_objet).objet)).semaphore), + (*((struct_semaphore *) (*s_objet).objet)).nom) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - - sprintf(chaine, "Semaphore $%s '%s'", tampon, - (*((struct_semaphore *) (*s_objet).objet)).nom); } else if ((*s_objet).type == SQL) { @@ -194,10 +159,14 @@ formateur(struct_processus *s_etat_proce "MYSQL") == 0) { # ifdef MYSQL_SUPPORT - sprintf(tampon, "Sql $%016lX (%s)", + if (alsprintf(&chaine, "Sql $ %016lX (%s)", (long unsigned int) (*((struct_connecteur_sql *) (*s_objet).objet)).descripteur.mysql, - (*((struct_connecteur_sql *) (*s_objet).objet)).type); + (*((struct_connecteur_sql *) (*s_objet).objet)).type) < 0) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return(NULL); + } # else if ((*s_etat_processus).langue == 'F') { @@ -217,10 +186,14 @@ formateur(struct_processus *s_etat_proce "POSTGRESQL") == 0) { # ifdef POSTGRESQL_SUPPORT - sprintf(tampon, "Sql $%016lX [ %s ]", + if (alsprintf(&chaine, "Sql $ %016lX (%s)", (long unsigned int) (*((struct_connecteur_sql *) - (*s_objet).objet)).descripteur.postgresql, - (*((struct_connecteur_sql *) (*s_objet).objet)).type); + (*s_objet).objet)).descripteur.mysql, + (*((struct_connecteur_sql *) (*s_objet).objet)).type) < 0) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return(NULL); + } # else if ((*s_etat_processus).langue == 'F') { @@ -242,17 +215,6 @@ formateur(struct_processus *s_etat_proce (*((struct_connecteur_sql *) (*s_objet).objet)) .type)); } - - chaine = (unsigned char *) malloc((strlen(tampon) + 1) - * sizeof(unsigned char)); - - if (chaine == NULL) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return(NULL); - } - - strcpy(chaine, tampon); } else if ((*s_objet).type == PRC) { @@ -266,41 +228,25 @@ formateur(struct_processus *s_etat_proce if ((*(*((struct_processus_fils *) (*s_objet).objet)).thread) .processus_detache == d_vrai) { - sprintf(tampon, " %016lX", (unsigned long) + if (alsprintf(&chaine, "Process $ %016lX", (unsigned long) (*(*((struct_processus_fils *) (*s_objet).objet)).thread) - .pid); - - chaine = (unsigned char *) malloc((strlen(tampon) + 10) - * sizeof(unsigned char)); - - if (chaine == NULL) + .pid) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - - strcpy(chaine, "Process $"); - strcat(chaine, tampon); } else { - sprintf(tampon, " %016lX/%016lX", + if (alsprintf(&chaine, "Light weight process $ %016lX/%016lX", (unsigned long) (*(*((struct_processus_fils *) (*s_objet).objet)).thread).pid, (unsigned long) (*(*((struct_processus_fils *) - (*s_objet).objet)).thread).tid); - - chaine = (unsigned char *) malloc((strlen(tampon) + 23) - * sizeof(unsigned char)); - - if (chaine == NULL) + (*s_objet).objet)).thread).tid) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - - strcpy(chaine, "Light weight process $"); - strcat(chaine, tampon); } } else if ((*s_objet).type == FCH) @@ -312,21 +258,13 @@ formateur(struct_processus *s_etat_proce -------------------------------------------------------------------------------- */ - sprintf(tampon, " %016lX", (unsigned long) (*((struct_fichier *) - ((*s_objet).objet))).descripteur); - - chaine = (unsigned char *) malloc((strlen(tampon) + 7) - * sizeof(unsigned char)); - - if (chaine == NULL) + if (alsprintf(&chaine, "File $ %016lX", (unsigned long) + (*((struct_fichier *) ((*s_objet).objet))).descripteur) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - strcpy(chaine, "File $"); - strcat(chaine, tampon); - registre45 = test_cfsf(s_etat_processus, 45); cf(s_etat_processus, 45); @@ -452,21 +390,14 @@ formateur(struct_processus *s_etat_proce -------------------------------------------------------------------------------- */ - sprintf(tampon, " %016lX", (unsigned long) (*((struct_socket *) - ((*s_objet).objet))).socket); - - chaine = (unsigned char *) malloc((strlen(tampon) + 9) - * sizeof(unsigned char)); - - if (chaine == NULL) + if (alsprintf(&chaine, "Socket %016lX", + (unsigned long) (*((struct_socket *) + ((*s_objet).objet))).socket) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - strcpy(chaine, "Socket $"); - strcat(chaine, tampon); - registre45 = test_cfsf(s_etat_processus, 45); cf(s_etat_processus, 45); @@ -3052,20 +2983,12 @@ formateur(struct_processus *s_etat_proce } else if ((*s_objet).type == MTX) { - sprintf(tampon, " %016lX", (unsigned long) - &((*((struct_mutex *) (*s_objet).objet)).mutex)); - - chaine = (unsigned char *) malloc((strlen(tampon) + 8) - * sizeof(unsigned char)); - - if (chaine == NULL) + if (alsprintf(&chaine, "Mutex $ %016lX", (unsigned long) + &((*((struct_mutex *) (*s_objet).objet)).mutex)) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return(NULL); } - - strcpy(chaine, "Mutex $"); - strcat(chaine, tampon); } else if ((*s_objet).type == NOM) { @@ -3517,10 +3440,10 @@ formateur_reel(struct_processus *s_etat_ long longueur_utile_limite; unsigned char *chaine; - unsigned char format[16 + 1]; + unsigned char format[32 + 1]; unsigned char mode[3 + 1]; unsigned char *ptr; - unsigned char tampon[16 + 1]; + unsigned char tampon[32 + 1]; unsigned long i; unsigned long j;