- elm_size = sub_type->aligned_size[GRAS_THISARCH];
- VERB2("Receive a %d-long array of %s",count, sub_type->name);
-
- ptr = l_data;
- for (cpt=0; cpt<count; cpt++) {
- TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
- r_arch, NULL, 0, ptr,-1));
- ptr += elm_size;
+ if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) {
+ VERB1("Array of %d scalars, get it in one shoot", count);
+ if (sub_type->aligned_size[GRAS_THISARCH] >=
+ sub_type->aligned_size[r_arch]) {
+ TRY(gras_trp_chunk_recv(sock, (char*)l_data,
+ sub_type->aligned_size[r_arch] * count));
+ TRY(gras_dd_convert_elm(sub_type,count,r_arch, l_data,l_data));
+ } else {
+ ptr = malloc((size_t)sub_type->aligned_size[r_arch] * count);
+ TRY(gras_trp_chunk_recv(sock, (char*)ptr,
+ sub_type->size[r_arch] * count));
+ TRY(gras_dd_convert_elm(sub_type,count,r_arch, ptr,l_data));
+ free(ptr);
+ }
+ } else {
+ /* not scalar content, get it recursively (may contain pointers) */
+ elm_size = sub_type->aligned_size[GRAS_THISARCH];
+ VERB2("Receive a %d-long array of %s",count, sub_type->name);
+
+ ptr = l_data;
+ for (cpt=0; cpt<count; cpt++) {
+ TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
+ r_arch, NULL, 0, ptr,-1));
+ ptr += elm_size;
+ }