67 static int init_gsds(
void);
68 static int check_numsets(
void);
69 static dataset *get_dataset(
int);
75 static int Numsets = 0;
77 static int Cur_id =
LUCKY;
79 static size_t Tot_mem = 0;
84 static int init_gsds(
void)
88 for (i = 0; i <
MAX_DS; i++) {
103 static int check_numsets(
void)
105 if (Numsets < Cur_max) {
123 static dataset *get_dataset(
int id)
127 for (i = 0; i < Numsets; i++) {
128 if (Data[i]->data_id ==
id) {
144 static int get_type(
dataset * ds)
193 start = begin ? 0 : i + 1;
195 for (i = start; i < Numsets; i++) {
196 if (!strcmp(Data[i]->unique_name, name)) {
197 if ((Data[i]->changed & *changes) || !(Data[i]->changed)) {
198 if (get_type(Data[i]) & *types) {
200 *types = get_type(Data[i]);
202 return (Data[i]->data_id);
222 static int first = 1;
226 if (0 > init_gsds()) {
232 else if (0 > check_numsets()) {
246 for (i = 0; i <
MAXDIMS; i++) {
250 new->unique_name =
G_store(name);
251 new->databuff.fb =
NULL;
252 new->databuff.ib =
NULL;
253 new->databuff.sb =
NULL;
254 new->databuff.cb =
NULL;
255 new->databuff.bm =
NULL;
256 new->databuff.nm =
NULL;
257 new->databuff.k = 0.0;
260 new->need_reload = 1;
262 return (new->data_id);
285 if ((ds = get_dataset(
id))) {
309 for (i = 0; i < Numsets; i++) {
310 if (Data[i]->data_id ==
id) {
336 for (i = 0; i < Numsets; i++) {
337 if (Data[i]->data_id ==
id) {
345 for (j = i; j < (Numsets - 1); j++) {
346 Data[j] = Data[j + 1];
374 for (i = 0; i < Numsets; i++) {
375 if (Data[i]->data_id ==
id) {
396 size_t siz, nsiz = 1, freed = 0;
398 for (i = 0; i < ds->
ndims; i++) {
422 siz = nsiz *
sizeof(char);
431 siz = nsiz *
sizeof(short);
440 siz = nsiz *
sizeof(int);
449 siz = nsiz *
sizeof(float);
460 G_debug(5,
"free_data_buffs(): freed data from id no. %d",
463 "free_data_buffs(): %.3f Kbytes freed, current total = %.3f",
464 freed / 1000., Tot_mem / 1000.);
488 if ((ds = get_dataset(
id))) {
496 for (i = 0; i < ndims; i++) {
497 ds->
dims[i] = dims[i];
546 siz *=
sizeof(short);
574 siz *=
sizeof(float);
598 "gsds_alloc_typbuff(): %f Kbytes allocated, current total = %f",
599 siz / 1000., Tot_mem / 1000.);
619 if ((ds = get_dataset(
id))) {
639 if ((ds = get_dataset(
id))) {
657 ds = get_dataset(
id);
659 return (get_type(ds));
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
size_t BM_get_map_size(struct BM *)
Returns size in bytes that bitmap is taking up.
int gsds_findh(const char *name, IFLAG *changes, IFLAG *types, int begin)
Get handle to gsds.
size_t gsds_alloc_typbuff(int id, int *dims, int ndims, int type)
Allocates correct buffer according to type, keeps track of total mem.
void G_free(void *)
Free allocated memory.
typbuff * gsds_get_typbuff(int id, IFLAG change_flag)
Get data buffer.
int BM_destroy(struct BM *)
Destroy bitmap and free all associated memory.
int gsds_get_type(int id)
ADD.
size_t free_data_buffs(dataset *ds, int typ)
Free data buffer.
char * gsds_get_name(int id)
Get name.
int gsds_free_data_buff(int id, int typ)
Free allocated buffer.
int gsds_get_changed(int id)
ADD.
struct BM * BM_create(int, int)
Create bitmap of dimension x/y and return structure token.
char * G_store(const char *)
Copy string to allocated memory.
int gsds_newh(const char *name)
Get handle to gsds.
int gsds_set_changed(int id, IFLAG reason)
ADD.
int G_debug(int, const char *,...) __attribute__((format(printf
int gsds_free_datah(int id)
Free allocated dataset.