1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| // Create an new element of the list to save the velocities and amplitudes.
struct AwacOrContConfigurationList* createNewElement(unsigned int nBins)
{
// Allocation for the new element of the list.
AwacOrContConfigurationList *element = malloc(sizeof(AwacOrContConfigurationList));
//printf("Alloction pour element effectuee\n");
if (element == NULL){
fprintf(stderr, "%s: Out of memory\n", __FILE__);
exit(MEMORY_ERROR);
}
// The element is a structure of one pointer for the data and one pointer towards the next element.
// Allocation for the data.
element->AwacOrContConfig = malloc(sizeof(AwacOrContConfiguration));
//printf("Alloction pour element->AwacOrContConfig effectuee\n");
if (element->AwacOrContConfig == NULL){
fprintf(stderr, "%s: Out of memory\n", __FILE__);
exit(MEMORY_ERROR);
}
// Memory allocation for the velocities and amplitude relativly to the number of cells.
element->AwacOrContConfig->Vel1 = malloc(nBins * sizeof(double));
if (element->AwacOrContConfig->Vel1 == NULL){
fprintf(stderr, "%s: Out of memory\n", "createNewElement Vel1");
exit(MEMORY_ERROR);
}
element->AwacOrContConfig->Vel2 = malloc(nBins * sizeof(double));
if (element->AwacOrContConfig->Vel2 == NULL){
fprintf(stderr, "%s: Out of memory\n", "createNewElement Vel2");
exit(MEMORY_ERROR);
}
element->AwacOrContConfig->Vel3 = malloc(nBins * sizeof(double));
if (element->AwacOrContConfig->Vel3 == NULL){
printf( "%s: Out of memory\n", "createNewElement Vel3" );
exit(MEMORY_ERROR);
}
element->AwacOrContConfig->amp1 = malloc(nBins * sizeof(int));
if ( element->AwacOrContConfig->amp1 == NULL ){
printf( "%s: Out of memory\n", "createNewElement amp1" );
exit( MEMORY_ERROR );
}
//printf("Alloction pour element->AwacOrContConfig->amp1 effectuee\n");
element->AwacOrContConfig->amp2 = malloc(nBins * sizeof(int)); // Plante ici
if ( element->AwacOrContConfig->amp2 == NULL ){
printf( "%s: Out of memory\n", "createNewElement amp2" );
exit( MEMORY_ERROR );
}
//printf("Alloction pour element->AwacOrContConfig->amp2 effectuee\n");
element->AwacOrContConfig->amp3 = malloc(nBins * sizeof(int));
if ( element->AwacOrContConfig->amp3 == NULL ){
printf( "%s: Out of memory\n", "createNewElement amp3" );
exit( MEMORY_ERROR );
}
//printf("Alloction pour element->AwacOrContConfig->amp3 effectuee\n");
element->next = NULL;
return element;
} |
Partager