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()) {
244 new->data_id = Cur_id++;
246 for (i = 0; i <
MAXDIMS; i++) {
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", ds->
data_id);
461 G_debug(5,
"free_data_buffs(): %.3f Kbytes freed, current total = %.3f",
462 freed / 1000., Tot_mem / 1000.);
486 if ((ds = get_dataset(
id))) {
494 for (i = 0; i < ndims; i++) {
495 ds->
dims[i] = dims[i];
544 siz *=
sizeof(short);
572 siz *=
sizeof(float);
596 "gsds_alloc_typbuff(): %f Kbytes allocated, current total = %f",
597 siz / 1000., Tot_mem / 1000.);
617 if ((ds = get_dataset(
id))) {
637 if ((ds = get_dataset(
id))) {
655 ds = get_dataset(
id);
657 return (get_type(ds));
int BM_destroy(struct BM *)
Destroy bitmap and free all associated memory.
size_t BM_get_map_size(struct BM *)
Returns size in bytes that bitmap is taking up.
struct BM * BM_create(int, int)
Create bitmap of dimension x/y and return structure token.
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
char * G_store(const char *)
Copy string to allocated memory.
int gsds_get_type(int id)
ADD.
int gsds_newh(const char *name)
Get handle to gsds.
int gsds_findh(const char *name, IFLAG *changes, IFLAG *types, int begin)
Get handle to gsds.
size_t free_data_buffs(dataset *ds, int typ)
Free data buffer.
char * gsds_get_name(int id)
Get name.
int gsds_set_changed(int id, IFLAG reason)
ADD.
int gsds_free_datah(int id)
Free allocated dataset.
typbuff * gsds_get_typbuff(int id, IFLAG change_flag)
Get data buffer.
size_t gsds_alloc_typbuff(int id, int *dims, int ndims, int type)
Allocates correct buffer according to type, keeps track of total mem.
int gsds_free_data_buff(int id, int typ)
Free allocated buffer.
int gsds_get_changed(int id)
ADD.