Exemple #1
0
/* Recursive type walker: reclaim a single instance */
static int
reclaim_datar(int ncid, int xtype, void* memory)
{
    int stat = NC_NOERR;
    
    switch  (xtype) {
    case NC_CHAR: case NC_BYTE: case NC_UBYTE: break;
    case NC_SHORT: case NC_USHORT: break;
    case NC_INT: case NC_UINT: case NC_FLOAT: break;
    case NC_INT64: case NC_UINT64: case NC_DOUBLE: break;
#ifdef USE_NETCDF4
    case NC_STRING: {
        char** sp = (char**)memory;
        /* Need to reclaim string */
	if(*sp != NULL) free(*sp);
	} break;
    default:
    	/* reclaim a user type */
	stat = reclaim_usertype(ncid,xtype,memory);
#else
    default:
	stat = NC_ENOTNC4;
#endif
	break;
    }
    return stat;
}
Exemple #2
0
/* Recursive type walker: reclaim a single instance */
static int
reclaim_datar(int ncid, int xtype, size_t typesize, Position* offset)
{
    int stat = NC_NOERR;

    switch  (xtype) {
    case NC_CHAR: case NC_BYTE: case NC_UBYTE:
    case NC_SHORT: case NC_USHORT:
    case NC_INT: case NC_UINT: case NC_FLOAT:
    case NC_INT64: case NC_UINT64: case NC_DOUBLE:
        offset->offset += typesize;
	break;

#ifdef USE_NETCDF4
    case NC_STRING: {
        char** sp = (char**)(offset->memory + offset->offset);
        /* Need to reclaim string */
	if(*sp != NULL) free(*sp);
	offset->offset += typesize;
	} break;
    default:
    	/* reclaim a user type */
	stat = reclaim_usertype(ncid,xtype,offset);
#else
    default:
	stat = NC_ENOTNC4;
#endif
	break;
    }
    return stat;
}