"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/src/gretl_array.c" between
gretl-2020a.tar.xz and gretl-2020b.tar.xz

About: gretl (Gnu Regression, Econometrics and Time-series Library) is a cross-platform statistical package mainly for econometric analysis.

gretl_array.c  (gretl-2020a.tar.xz):gretl_array.c  (gretl-2020b.tar.xz)
skipping to change at line 483 skipping to change at line 483
int gretl_array_set_data (gretl_array *A, int i, void *ptr) int gretl_array_set_data (gretl_array *A, int i, void *ptr)
{ {
if (A == NULL || i < 0 || i >= A->n) { if (A == NULL || i < 0 || i >= A->n) {
return E_DATA; return E_DATA;
} else { } else {
A->data[i] = ptr; A->data[i] = ptr;
return 0; return 0;
} }
} }
gretl_array *gretl_array_copy_range (gretl_array *A, static int check_list_bounds (int *list, int arrdim)
int r1, int r2, {
int *err) int i;
for (i=1; i<=list[0]; i++) {
if (list[i] <= 0 || list[i] > arrdim) {
return 0;
}
}
return 1;
}
gretl_array *gretl_array_copy_subspec (gretl_array *A,
int *list,
int *err)
{ {
gretl_array *C = NULL; gretl_array *C = NULL;
if (A == NULL) { if (A == NULL) {
*err = E_DATA; *err = E_DATA;
} else if (r1 < 0 || r1 >= A->n || r2 < r1 || r2 >= A->n) { } else if (!check_list_bounds(list, A->n)) {
*err = E_INVARG; *err = E_INVARG;
} else { } else {
C = gretl_array_new(A->type, r2 - r1 + 1, err); int i, k, m = list[0];
if (!*err) {
int i, j = 0; C = gretl_array_new(A->type, m, err);
for (i=r1; i<=r2 && !*err; i++) { for (i=0; i<m && !*err; i++) {
if (A->data[i] != NULL) { k = list[i+1] - 1;
if (A->type == GRETL_TYPE_STRINGS) { if (A->data[k] != NULL) {
C->data[j] = gretl_strdup(A->data[i]); if (A->type == GRETL_TYPE_STRINGS) {
} else if (A->type == GRETL_TYPE_MATRICES) { C->data[i] = gretl_strdup(A->data[k]);
C->data[j] = gretl_matrix_copy(A->data[i]); } else if (A->type == GRETL_TYPE_MATRICES) {
} else if (A->type == GRETL_TYPE_BUNDLES) { C->data[i] = gretl_matrix_copy(A->data[k]);
C->data[j] = gretl_bundle_copy(A->data[i], err); } else if (A->type == GRETL_TYPE_BUNDLES) {
} else if (A->type == GRETL_TYPE_ARRAYS) { C->data[i] = gretl_bundle_copy(A->data[k], err);
C->data[j] = gretl_array_copy(A->data[i], err); } else if (A->type == GRETL_TYPE_ARRAYS) {
} else { C->data[i] = gretl_array_copy(A->data[k], err);
C->data[j] = gretl_list_copy(A->data[i]); } else {
} C->data[i] = gretl_list_copy(A->data[k]);
if (!*err && C->data[j] == NULL) { }
*err = E_ALLOC; if (!*err && C->data[i] == NULL) {
} *err = E_ALLOC;
} }
j++;
} }
} }
} }
if (*err && C != NULL) {
gretl_array_destroy(C);
C = NULL;
}
return C; return C;
} }
gretl_bundle *gretl_array_get_bundle (gretl_array *A, int i) gretl_bundle *gretl_array_get_bundle (gretl_array *A, int i)
{ {
gretl_bundle *b = NULL; gretl_bundle *b = NULL;
/* The bundle returned here is not "deep copied", /* The bundle returned here is not "deep copied",
we just pass the pointer. It's up to the caller to we just pass the pointer. It's up to the caller to
decide if a copy has to be made, given that the decide if a copy has to be made, given that the
 End of changes. 5 change blocks. 
25 lines changed or deleted 42 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)