- TRY(gras_datadesc_by_id(array_data.code, &sub_type));
- elm_size = sub_type->aligned_size[GRAS_THISARCH];
- VERB2("Receive a %d-long array of %s",count, sub_type->name);
-
- if (!l_data) {
- TRY(gras_dd_alloc_ref(refs,elm_size*count,r_data,r_lgr, &l_data));
- }
-
- ptr = l_data;
- for (cpt=0; cpt<count; cpt++) {
- TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
- r_arch, NULL, 0, ptr));
- ptr += elm_size;
+ sub_type = array_data.type;
+ 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));
+ if (r_arch != GRAS_THISARCH)
+ TRY(gras_dd_convert_elm(sub_type,count,r_arch, l_data,l_data));
+ } else {
+ ptr = gras_malloc(sub_type->aligned_size[r_arch] * count);
+
+ TRY(gras_trp_chunk_recv(sock, (char*)ptr,
+ sub_type->size[r_arch] * count));
+ if (r_arch != GRAS_THISARCH)
+ TRY(gras_dd_convert_elm(sub_type,count,r_arch, ptr,l_data));
+ gras_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,
+ detect_cycle || sub_type->cycle));
+ ptr += elm_size;
+ }