Question de c

Startseite

Nachricht beantworten
Autor: Patrick Dupre
Datum:  
To: guilde
Betreff: Question de c
Bonsoir,

Est-ce que j'ai le droit de faire ceci ,


typedef struct {
double x, abs_lin, dis_lin, abs_sat, dis_sat ;
} profile_str ;


profile_str *order_test (const double *restrict x, const double *restrict y1, const double *restrict y2, const double complex *restrict y, const unsigned short nbpt) {
  profile_str *prof = MALLOC (nbpt, profile_str) ;
  for (short int i = nbpt - 1 ; i >= 0 ; i--) {
    const unsigned short int j = nbpt - i - 1 ;
    profile_str *const prof_elem = &prof [j] ;
    prof_elem -> x = -x [i] ;
    prof_elem -> abs_lin = y1 [i] ;
    prof_elem -> dis_lin = y2 [i] ;
    prof_elem -> abs_sat = creal (y [i]) ;
    prof_elem -> dis_sat = cimag (y [i]) ;
    }
for (unsigned short int i = 1 ; i < nbpt ; i++) {
    const unsigned short int j =  i + nbpt - 1 ;
    profile_str *const prof_elem = &prof [j] ;
    prof_elem -> x = x [i] ;
    prof_elem -> abs_lin = y1 [i] ;
    prof_elem -> dis_lin = -y2 [i] ;
    prof_elem -> abs_sat = creal (y [i]) ;
    prof_elem -> dis_sat = -cimag (y [i]) ;
    }
 return prof ;
}


main () {
profile_str *profile = order_test (x_half_profile, werf_r, werf_i, sat_profile, nbpt_half_profile) ;
}

Ca a l'air de marche, mais jeme retrpuve avec

free(): corrupted unsorted chunks
Aborted (core dumped)

Et je ne comprends pas

Merci pour les lumieres.



===========================================================================
 Patrick DUPRÉ                                 | | email: pdupre@???
 Laboratoire interdisciplinaire Carnot de Bourgogne
 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE
 Tel: +33 (0)380395988                    | | Room# D114A
===========================================================================