conflict resolution

This commit is contained in:
dmh 2014-03-10 16:41:35 -06:00
commit e1c4e79757
16 changed files with 157 additions and 143 deletions

View File

@ -633,13 +633,15 @@ AC_ARG_ENABLE([diskless],
[AS_HELP_STRING([--disable-diskless],
[disable support for in-memory (NC_DISKLESS) files])])
test "x$enable_diskless" = xno || enable_diskless=yes
AC_MSG_RESULT($enable_diskless)
if test "x$enable_dap" = "xyes" -o "x$enable_cdmremote" = "xyes" -o "x$enable_rpc" = "xyes" ; then
enable_diskless=yes
AC_MSG_NOTICE([--enable-dap requires --enable-diskless])
fi
AC_MSG_RESULT($enable_diskless)
# check for useful, but not essential, memio support
AC_CHECK_FUNCS([memmove getpagesize sysconf])

View File

@ -6,8 +6,8 @@
typedef struct NCbytes {
int nonextendible; /* 1 => fail if an attempt is made to extend this buffer*/
size_t alloc;
size_t length;
unsigned long alloc;
unsigned long length;
char* content;
} NCbytes;
@ -19,8 +19,8 @@ typedef struct NCbytes {
EXTERNC NCbytes* ncbytesnew(void);
EXTERNC void ncbytesfree(NCbytes*);
EXTERNC int ncbytessetalloc(NCbytes*,size_t);
EXTERNC int ncbytessetlength(NCbytes*,size_t);
EXTERNC int ncbytessetalloc(NCbytes*,unsigned long);
EXTERNC int ncbytessetlength(NCbytes*,unsigned long);
EXTERNC int ncbytesfill(NCbytes*, char fill);
/* Produce a duplicate of the contents*/
@ -29,14 +29,14 @@ EXTERNC char* ncbytesdup(NCbytes*);
EXTERNC char* ncbytesextract(NCbytes*);
/* Return the ith byte; -1 if no such index */
EXTERNC int ncbytesget(NCbytes*,size_t);
EXTERNC int ncbytesget(NCbytes*,unsigned long);
/* Set the ith byte */
EXTERNC int ncbytesset(NCbytes*,size_t,char);
EXTERNC int ncbytesset(NCbytes*,unsigned long,char);
/* Append one byte */
EXTERNC int ncbytesappend(NCbytes*,int); /* Add at Tail */
EXTERNC int ncbytesappend(NCbytes*,char); /* Add at Tail */
/* Append n bytes */
EXTERNC int ncbytesappendn(NCbytes*,const void*,size_t); /* Add at Tail */
EXTERNC int ncbytesappendn(NCbytes*,const void*,unsigned long); /* Add at Tail */
/* Null terminate the byte string without extending its length (for debugging) */
EXTERNC int ncbytesnull(NCbytes*);
@ -45,7 +45,7 @@ EXTERNC int ncbytesnull(NCbytes*);
EXTERNC int ncbytescat(NCbytes*,const char*);
/* Set the contents of the buffer; mark the buffer as non-extendible */
EXTERNC int ncbytessetcontents(NCbytes*, char*, size_t);
EXTERNC int ncbytessetcontents(NCbytes*, char*, unsigned long);
/* Following are always "in-lined"*/
#define ncbyteslength(bb) ((bb)!=NULL?(bb)->length:0)

View File

@ -358,7 +358,7 @@ extern int NCDAP_ping(const char*);
/* Misc */
extern int NC_getshape(int ncid, int varid, size_t ndims, size_t* shape);
extern int NC_getshape(int ncid, int varid, int ndims, size_t* shape);
extern int NC_is_recvar(int ncid, int varid, size_t* nrecs);
#define nullstring(s) (s==NULL?"(null)":s)

View File

@ -20,13 +20,13 @@ typedef unsigned long nchashid;
externC int nchashnull(void*);
typedef struct NChashmap {
int alloc;
int size; /* # of pairs still in table*/
size_t alloc;
size_t size; /* # of pairs still in table*/
NClist** table;
} NChashmap;
externC NChashmap* nchashnew(void);
externC NChashmap* nchashnew0(int);
externC NChashmap* nchashnew0(size_t);
externC int nchashfree(NChashmap*);
/* Insert a (ncnchashid,void*) pair into the table*/
@ -48,7 +48,7 @@ externC int nchashremove(NChashmap*, nchashid nchash);
/* Return the ith pair; order is completely arbitrary*/
/* Can be expensive*/
externC int nchashith(NChashmap*, size_t i, nchashid*, void**);
externC int nchashith(NChashmap*, int i, nchashid*, void**);
externC int nchashkeys(NChashmap* hm, nchashid** keylist);

View File

@ -197,7 +197,8 @@ NC_dispatch_overlay(const NC_Dispatch* overlay, const NC_Dispatch* base, NC_Disp
{
void** voverlay = (void**)overlay;
void** vmerge;
int i, count = sizeof(NC_Dispatch) / sizeof(void*);
int i;
size_t count = sizeof(NC_Dispatch) / sizeof(void*);
/* dispatch table must be exact multiple of sizeof(void*) */
assert(count * sizeof(void*) == sizeof(NC_Dispatch));
*merge = *base;

View File

@ -123,7 +123,7 @@ NC_check_file_type(const char *path, int use_parallel, void *mpi_info,
#endif /* USE_PARALLEL */
{
FILE *fp;
int i;
size_t i;
#ifdef HAVE_SYS_STAT_H
struct stat st;
#endif
@ -1799,9 +1799,9 @@ nc__pseudofd(void)
struct rlimit rl;
if(getrlimit(RLIMIT_NOFILE,&rl) == 0) {
if(rl.rlim_max != RLIM_INFINITY)
maxfd = rl.rlim_max;
maxfd = (int)rl.rlim_max;
if(rl.rlim_cur != RLIM_INFINITY)
maxfd = rl.rlim_cur;
maxfd = (int)rl.rlim_cur;
}
pseudofd = maxfd+1;
#endif

View File

@ -164,11 +164,11 @@ ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
if (uc < 0x00) {
return 0;
} else if (uc < 0x80) {
dst[0] = uc;
dst[0] = (uint8_t)uc;
return 1;
} else if (uc < 0x800) {
dst[0] = 0xC0 + (uc >> 6);
dst[1] = 0x80 + (uc & 0x3F);
dst[0] = (uint8_t)(0xC0 + (uc >> 6));
dst[1] = (uint8_t)(0x80 + (uc & 0x3F));
return 2;
} else if (uc == 0xFFFF) {
dst[0] = 0xFF;
@ -177,15 +177,15 @@ ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
dst[0] = 0xFE;
return 1;
} else if (uc < 0x10000) {
dst[0] = 0xE0 + (uc >> 12);
dst[1] = 0x80 + ((uc >> 6) & 0x3F);
dst[2] = 0x80 + (uc & 0x3F);
dst[0] = (uint8_t)(0xE0 + (uc >> 12));
dst[1] = (uint8_t)(0x80 + ((uc >> 6) & 0x3F));
dst[2] = (uint8_t)(0x80 + (uc & 0x3F));
return 3;
} else if (uc < 0x110000) {
dst[0] = 0xF0 + (uc >> 18);
dst[1] = 0x80 + ((uc >> 12) & 0x3F);
dst[2] = 0x80 + ((uc >> 6) & 0x3F);
dst[3] = 0x80 + (uc & 0x3F);
dst[0] = (uint8_t)(0xF0 + (uc >> 18));
dst[1] = (uint8_t)(0x80 + ((uc >> 12) & 0x3F));
dst[2] = (uint8_t)(0x80 + ((uc >> 6) & 0x3F));
dst[3] = (uint8_t)(0x80 + (uc & 0x3F));
return 4;
} else return 0;
}
@ -533,7 +533,7 @@ ssize_t utf8proc_map(
*dstptr = NULL;
result = utf8proc_decompose(str, slen, NULL, 0, options);
if (result < 0) return result;
buffer = malloc(result * sizeof(int32_t) + 1);
buffer = (int32_t*)malloc(((size_t)result) * sizeof(int32_t) + 1);
if (!buffer) return UTF8PROC_ERROR_NOMEM;
result = utf8proc_decompose(str, slen, buffer, result, options);
if (result < 0) {
@ -547,7 +547,7 @@ ssize_t utf8proc_map(
}
{
int32_t *newptr;
newptr = realloc(buffer, (size_t)result+1);
newptr = realloc(buffer, result+1);
if (newptr) buffer = newptr;
}
*dstptr = (uint8_t *)buffer;

View File

@ -104,7 +104,7 @@ typedef signed char schar;
* the record variable ids, if the array parameter is non-null.
*/
static int
numrecvars(int ncid, int *nrecvarsp, int *recvarids)
numrecvars(int ncid, int* nrecvarsp, int *recvarids)
{
int status = NC_NOERR;
int nvars = 0;
@ -158,7 +158,7 @@ ncrecsize(int ncid, int varid, size_t *recsizep)
int ndims;
int dimids[MAX_NC_DIMS];
int id;
size_t size;
int size;
*recsizep = 0;
status = nc_inq_unlimdim(ncid, &recdimid);
@ -182,9 +182,9 @@ ncrecsize(int ncid, int varid, size_t *recsizep)
status = nc_inq_dimlen(ncid, dimids[id], &len);
if(status != NC_NOERR)
return status;
size *= len;
size *= (int)len;
}
*recsizep = size;
*recsizep = (size_t)size;
return NC_NOERR;
}
@ -256,7 +256,7 @@ nc_inq_rec(
return status;
if (nrecvarsp != NULL)
*nrecvarsp = nrvars;
*nrecvarsp = (size_t)nrvars;
if (recvarids != NULL)
for (varid = 0; varid < nrvars; varid++)
recvarids[varid] = rvarids[varid];
@ -964,7 +964,7 @@ ncattput(
const void* value
)
{
const int status = nc_put_att(ncid, varid, name, datatype, (size_t)len, value);
const int status = nc_put_att(ncid, varid, name, datatype, len, value);
if(status != NC_NOERR)
{
nc_advise("ncattput", status, "ncid %d", ncid);

View File

@ -329,32 +329,32 @@ nctypelen(nc_type type)
{
switch(type){
case NC_CHAR :
return((int)sizeof(char));
return ((int)sizeof(char));
case NC_BYTE :
return((int)sizeof(signed char));
return ((int)sizeof(signed char));
case NC_SHORT :
return(int)(sizeof(short));
return ((int)sizeof(short));
case NC_INT :
return((int)sizeof(int));
return ((int)sizeof(int));
case NC_FLOAT :
return((int)sizeof(float));
return ((int)sizeof(float));
case NC_DOUBLE :
return((int)sizeof(double));
return ((int)sizeof(double));
/* These can occur in netcdf-3 code */
case NC_UBYTE :
return((int)sizeof(unsigned char));
return ((int)sizeof(unsigned char));
case NC_USHORT :
return((int)(sizeof(unsigned short)));
return ((int)(sizeof(unsigned short)));
case NC_UINT :
return((int)sizeof(unsigned int));
return ((int)sizeof(unsigned int));
case NC_INT64 :
return((int)sizeof(signed long long));
return ((int)sizeof(signed long long));
case NC_UINT64 :
return((int)sizeof(unsigned long long));
return ((int)sizeof(unsigned long long));
#ifdef USE_NETCDF4
case NC_STRING :
return((int)sizeof(char*));
return ((int)sizeof(char*));
#endif /*USE_NETCDF4*/
default:
@ -423,7 +423,7 @@ NC_atomictypename(nc_type xtype)
Get the shape of a variable.
*/
int
NC_getshape(int ncid, int varid, size_t ndims, size_t* shape)
NC_getshape(int ncid, int varid, int ndims, size_t* shape)
{
int dimids[NC_MAX_VAR_DIMS];
int i;

View File

@ -19,7 +19,7 @@ struct GETodometer {
static void
odom_init(struct GETodometer* odom,
size_t rank,
int rank,
const size_t* start, const size_t* edges, const ptrdiff_t* stride)
{
int i;
@ -30,7 +30,7 @@ odom_init(struct GETodometer* odom,
odom->start[i] = (start != NULL ? start[i] : 0);
odom->edges[i] = (edges != NULL ? edges[i] : 1);
odom->stride[i] = (stride != NULL ? stride[i] : 1);
odom->stop[i] = odom->start[i] + (odom->edges[i]*odom->stride[i]);
odom->stop[i] = odom->start[i] + (odom->edges[i]*((size_t)odom->stride[i]));
odom->index[i] = odom->start[i];
}
}
@ -47,7 +47,7 @@ odom_next(struct GETodometer* odom)
int i;
if(odom->rank == 0) return 0;
for(i=odom->rank-1;i>=0;i--) {
odom->index[i] += odom->stride[i];
odom->index[i] += (size_t)odom->stride[i];
if(odom->index[i] < odom->stop[i]) break;
if(i == 0) return 0; /* leave the 0th entry if it overflows*/
odom->index[i] = odom->start[i]; /* reset this position*/
@ -73,7 +73,7 @@ NC_get_vara(int ncid, int varid,
#endif
if(edges == NULL) {
size_t shape[NC_MAX_VAR_DIMS];
size_t ndims;
int ndims;
stat = nc_inq_varndims(ncid, varid, &ndims);
if(stat != NC_NOERR) return stat;
stat = NC_getshape(ncid,varid,ndims,shape);
@ -89,7 +89,7 @@ NC_get_vara(int ncid, int varid,
static int
NC_get_var(int ncid, int varid, void *value, nc_type memtype)
{
size_t ndims;
int ndims;
size_t shape[NC_MAX_VAR_DIMS];
int stat = nc_inq_varndims(ncid,varid, &ndims);
if(stat) return stat;
@ -118,11 +118,12 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
int status = NC_NOERR;
int i,simplestride,isrecvar;
size_t rank;
int rank;
struct GETodometer odom;
nc_type vartype = NC_NAT;
NC* ncp;
size_t vartypelen, memtypelen;
int memtypelen;
size_t vartypelen;
char* value = (char*)value0;
size_t numrecs;
size_t varshape[NC_MAX_VAR_DIMS];
@ -144,7 +145,7 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
if(status != NC_NOERR) return status;
if(memtype > NC_MAX_ATOMIC_TYPE)
memtypelen = vartypelen;
memtypelen = (int)vartypelen;
else
memtypelen = nctypelen(memtype);
@ -257,9 +258,9 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
{
int status = NC_NOERR;
nc_type vartype = NC_NAT;
size_t varndims,maxidim;
int varndims,maxidim;
NC* ncp;
size_t memtypelen;
int memtypelen;
ptrdiff_t cvtmap[NC_MAX_VAR_DIMS];
char* value = (char*)value0;
@ -364,7 +365,7 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
/* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
/* Allocate space for mystart,mystride,mymap etc.all at once */
mystart = (size_t *)calloc(varndims * 7, sizeof(ptrdiff_t));
mystart = (size_t *)calloc((size_t)(varndims * 7), sizeof(ptrdiff_t));
if(mystart == NULL) return NC_ENOMEM;
myedges = mystart + varndims;
iocount = myedges + varndims;
@ -423,8 +424,8 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
#endif
iocount[idim] = 1;
length[idim] = mymap[idim] * myedges[idim];
stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
length[idim] = ((size_t)mymap[idim]) * myedges[idim];
stop[idim] = (mystart[idim] + myedges[idim] * (size_t)mystride[idim]);
}
/*
@ -486,12 +487,13 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
*/
idim = maxidim;
carry:
value += (mymap[idim] * memtypelen);
mystart[idim] += mystride[idim];
value += (((int)mymap[idim]) * memtypelen);
mystart[idim] += (size_t)mystride[idim];
if (mystart[idim] == stop[idim])
{
size_t l = (length[idim] * (size_t)memtypelen);
value -= l;
mystart[idim] = start[idim];
value -= (length[idim] * memtypelen);
if (--idim < 0)
break; /* normal return */
goto carry;

View File

@ -20,7 +20,7 @@ struct PUTodometer {
static void
odom_init(struct PUTodometer* odom,
size_t rank,
int rank,
const size_t* start, const size_t* edges, const ptrdiff_t* stride)
{
int i;
@ -31,7 +31,7 @@ odom_init(struct PUTodometer* odom,
odom->start[i] = (start != NULL ? start[i] : 0);
odom->edges[i] = (edges != NULL ? edges[i] : 1);
odom->stride[i] = (stride != NULL ? stride[i] : 1);
odom->stop[i] = odom->start[i] + (odom->edges[i]*odom->stride[i]);
odom->stop[i] = odom->start[i] + (odom->edges[i]*(size_t)odom->stride[i]);
odom->index[i] = odom->start[i];
}
}
@ -48,7 +48,7 @@ odom_next(struct PUTodometer* odom)
int i;
if(odom->rank == 0) return 0;
for(i=odom->rank-1;i>=0;i--) {
odom->index[i] += odom->stride[i];
odom->index[i] += (size_t)odom->stride[i];
if(odom->index[i] < odom->stop[i]) break;
if(i == 0) return 0; /* leave the 0th entry if it overflows*/
odom->index[i] = odom->start[i]; /* reset this position*/
@ -69,7 +69,7 @@ NC_put_vara(int ncid, int varid, const size_t *start,
if(stat != NC_NOERR) return stat;
if(edges == NULL) {
size_t shape[NC_MAX_VAR_DIMS];
size_t ndims;
int ndims;
stat = nc_inq_varndims(ncid, varid, &ndims);
if(stat != NC_NOERR) return stat;
stat = NC_getshape(ncid, varid, ndims, shape);
@ -85,7 +85,7 @@ NC_put_vara(int ncid, int varid, const size_t *start,
static int
NC_put_var(int ncid, int varid, const void *value, nc_type memtype)
{
size_t ndims;
int ndims;
size_t shape[NC_MAX_VAR_DIMS];
int stat = nc_inq_varndims(ncid,varid, &ndims);
if(stat) return stat;
@ -123,11 +123,12 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
int status = NC_NOERR;
int i,simplestride,isrecvar;
size_t rank;
int rank;
struct PUTodometer odom;
nc_type vartype = NC_NAT;
NC* ncp;
size_t vartypelen, memtypelen;
size_t vartypelen;
int memtypelen;
const char* value = (const char*)value0;
size_t numrecs;
size_t varshape[NC_MAX_VAR_DIMS];
@ -150,7 +151,7 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
if(status != NC_NOERR) return status;
if(memtype > NC_MAX_ATOMIC_TYPE)
memtypelen = vartypelen;
memtypelen = (int)vartypelen;
else
memtypelen = nctypelen(memtype);
@ -265,10 +266,10 @@ NCDEFAULT_put_varm(
{
int status = NC_NOERR;
nc_type vartype = NC_NAT;
size_t varndims = 0;
size_t maxidim = 0;
int varndims = 0;
int maxidim = 0;
NC* ncp;
size_t memtypelen;
int memtypelen;
ptrdiff_t cvtmap[NC_MAX_VAR_DIMS];
const char* value = (char*)value0;
@ -375,7 +376,7 @@ NCDEFAULT_put_varm(
NC_getshape(ncid,varid,varndims,varshape);
/* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
mystart = (size_t *)calloc(varndims * 7, sizeof(ptrdiff_t));
mystart = (size_t *)calloc((size_t)(varndims * 7), sizeof(ptrdiff_t));
if(mystart == NULL) return NC_ENOMEM;
myedges = mystart + varndims;
iocount = myedges + varndims;
@ -414,8 +415,8 @@ NCDEFAULT_put_varm(
: mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
iocount[idim] = 1;
length[idim] = mymap[idim] * myedges[idim];
stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
length[idim] = ((size_t)mymap[idim]) * myedges[idim];
stop[idim] = mystart[idim] + myedges[idim] * (size_t)mystride[idim];
}
/*
@ -472,11 +473,12 @@ NCDEFAULT_put_varm(
idim = maxidim;
carry:
value += (mymap[idim] * memtypelen);
mystart[idim] += mystride[idim];
mystart[idim] += (size_t)mystride[idim];
if (mystart[idim] == stop[idim])
{
size_t l = (length[idim] * (size_t)memtypelen);
value -= l;
mystart[idim] = start[idim];
value -= (length[idim] * memtypelen);
if (--idim < 0)
break; /* normal return */
goto carry;

View File

@ -1,4 +1,3 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
@ -29,7 +28,7 @@ Author: D. Heimbigner 10/7/2008
struct NCAUX_FIELD {
char* name;
nc_type fieldtype;
int ndims;
size_t ndims;
int dimsizes[NC_MAX_VAR_DIMS];
size_t size;
size_t offset;
@ -40,7 +39,7 @@ struct NCAUX_CMPD {
int ncid;
int mode;
char* name;
int nfields;
size_t nfields;
struct NCAUX_FIELD* fields;
size_t size;
size_t offset; /* cumulative as fields are added */
@ -126,8 +125,8 @@ ncaux_add_field(void* tag, const char *name, nc_type field_type,
field->name = strdup(name);
field->fieldtype = field_type;
if(field->name == NULL) {status = NC_ENOMEM; goto done;}
field->ndims = ndims;
memcpy(field->dimsizes,dimsizes,sizeof(int)*ndims);
field->ndims = (size_t)ndims;
memcpy(field->dimsizes,dimsizes,sizeof(int)*field->ndims);
cmpd->nfields++;
done:
@ -135,11 +134,11 @@ done:
}
static size_t
dimproduct(int ndims, int* dimsizes)
dimproduct(size_t ndims, int* dimsizes)
{
int i;
size_t product = 1;
for(i=0;i<ndims;i++) product *= dimsizes[i];
for(i=0;i<ndims;i++) product *= (size_t)dimsizes[i];
return product;
}
@ -167,7 +166,7 @@ ncaux_end_compound(void* tag, nc_type* idp)
} else {
status = nc_insert_array_compound(cmpd->ncid, *idp, field->name,
field->offset, field->fieldtype,
field->ndims,field->dimsizes);
(int)field->ndims,field->dimsizes);
}
if(status != NC_NOERR) goto done;
}
@ -224,7 +223,7 @@ It seems to work for HDF5 for a wide variety of machines.
typedef struct Alignment {
char* typename;
int alignment;
size_t alignment;
} Alignment;
typedef Alignment Typealignvec;
@ -317,11 +316,11 @@ nctypealignment(nc_type nctype)
return align->alignment;
}
static int
static size_t
getpadding(size_t offset, size_t alignment)
{
int rem = (alignment==0?0:(offset % alignment));
int pad = (rem==0?0:(alignment - rem));
size_t rem = (alignment==0?0:(offset % alignment));
size_t pad = (rem==0?0:(alignment - rem));
return pad;
}
@ -360,7 +359,7 @@ computefieldinfo(struct NCAUX_CMPD* cmpd)
for(offset=0,i=0;i<cmpd->nfields;i++) {
struct NCAUX_FIELD* field = &cmpd->fields[i];
size_t alignment = 0;
int alignment = 0;
nc_type firsttype = findfirstfield(cmpd->ncid,field->fieldtype);
/* only support 'c' alignment for now*/

View File

@ -19,7 +19,7 @@
static int ncbytesdebug = 1;
static long
static int
ncbytesfail(void)
{
fflush(stdout);
@ -33,7 +33,7 @@ NCbytes*
ncbytesnew(void)
{
NCbytes* bb = (NCbytes*)malloc(sizeof(NCbytes));
if(bb == NULL) return (NCbytes*)ncbytesfail();
if(bb == NULL) return (ncbytesfail(),NULL);
bb->alloc=0;
bb->length=0;
bb->content=NULL;
@ -42,7 +42,7 @@ ncbytesnew(void)
}
int
ncbytessetalloc(NCbytes* bb, size_t sz)
ncbytessetalloc(NCbytes* bb, unsigned long sz)
{
char* newcontent;
if(bb == NULL) return ncbytesfail();
@ -69,7 +69,7 @@ ncbytesfree(NCbytes* bb)
}
int
ncbytessetlength(NCbytes* bb, size_t sz)
ncbytessetlength(NCbytes* bb, unsigned long sz)
{
if(bb == NULL) return ncbytesfail();
if(bb->length < sz) {
@ -82,14 +82,14 @@ ncbytessetlength(NCbytes* bb, size_t sz)
int
ncbytesfill(NCbytes* bb, char fill)
{
size_t i;
unsigned long i;
if(bb == NULL) return ncbytesfail();
for(i=0;i<bb->length;i++) bb->content[i] = fill;
return TRUE;
}
int
ncbytesget(NCbytes* bb, size_t index)
ncbytesget(NCbytes* bb, unsigned long index)
{
if(bb == NULL) return -1;
if(index >= bb->length) return -1;
@ -97,7 +97,7 @@ ncbytesget(NCbytes* bb, size_t index)
}
int
ncbytesset(NCbytes* bb, size_t index, char elem)
ncbytesset(NCbytes* bb, unsigned long index, char elem)
{
if(bb == NULL) return ncbytesfail();
if(index >= bb->length) return ncbytesfail();
@ -106,14 +106,14 @@ ncbytesset(NCbytes* bb, size_t index, char elem)
}
int
ncbytesappend(NCbytes* bb, int elem)
ncbytesappend(NCbytes* bb, char elem)
{
if(bb == NULL) return ncbytesfail();
/* We need space for the char + null */
while(bb->length+1 >= bb->alloc) {
if(!ncbytessetalloc(bb,0)) return ncbytesfail();
}
bb->content[bb->length] = (elem & 0xFF);
bb->content[bb->length] = (char)(elem & 0xFF);
bb->length++;
bb->content[bb->length] = '\0';
return TRUE;
@ -134,7 +134,7 @@ ncbytescat(NCbytes* bb, const char* s)
}
int
ncbytesappendn(NCbytes* bb, const void* elem, size_t n)
ncbytesappendn(NCbytes* bb, const void* elem, unsigned long n)
{
if(bb == NULL || elem == NULL) return ncbytesfail();
if(n == 0) {n = strlen((char*)elem);}
@ -154,7 +154,7 @@ ncbytesprepend(NCbytes* bb, char elem)
if(bb == NULL) return ncbytesfail();
if(bb->length >= bb->alloc) if(!ncbytessetalloc(bb,0)) return ncbytesfail();
/* could we trust memcpy? instead */
for(i=bb->alloc;i>=1;i--) {bb->content[i]=bb->content[i-1];}
for(i=(int)bb->alloc;i>=1;i--) {bb->content[i]=bb->content[i-1];}
bb->content[0] = elem;
bb->length++;
return TRUE;
@ -180,7 +180,7 @@ ncbytesextract(NCbytes* bb)
}
int
ncbytessetcontents(NCbytes* bb, char* contents, size_t alloc)
ncbytessetcontents(NCbytes* bb, char* contents, unsigned long alloc)
{
if(bb == NULL) return ncbytesfail();
ncbytesclear(bb);
@ -197,7 +197,7 @@ ncbytessetcontents(NCbytes* bb, char* contents, size_t alloc)
int
ncbytesnull(NCbytes* bb)
{
ncbytesappend(bb,(int)'\0');
ncbytesappend(bb,'\0');
bb->length--;
return 1;
}

View File

@ -25,7 +25,7 @@
NChashmap* nchashnew(void) {return nchashnew0(DEFAULTALLOC);}
NChashmap* nchashnew0(int alloc)
NChashmap* nchashnew0(size_t alloc)
{
NChashmap* hm;
if(sizeof(nchashid) != sizeof(void*)){
@ -60,7 +60,8 @@ nchashfree(NChashmap* hm)
int
nchashinsert(NChashmap* hm, nchashid hash, void* value)
{
int i,offset,len;
int i;
size_t offset,len;
NClist* seq;
void** list;
@ -83,7 +84,8 @@ nchashinsert(NChashmap* hm, nchashid hash, void* value)
int
nchashreplace(NChashmap* hm, nchashid hash, void* value)
{
int i,offset,len;
int i;
size_t offset,len;
NClist* seq;
void** list;
@ -106,7 +108,8 @@ nchashreplace(NChashmap* hm, nchashid hash, void* value)
int
nchashremove(NChashmap* hm, nchashid hash)
{
size_t i,offset,len;
size_t i;
size_t offset,len;
NClist* seq;
void** list;
@ -117,7 +120,7 @@ nchashremove(NChashmap* hm, nchashid hash)
list = nclistcontents(seq);
for(i=0;i<len;i+=2,list+=2) {
if(hash==(nchashid)(*list)) {
nclistremove(seq,i+1);
nclistremove(seq,(i+1));
nclistremove(seq,i);
hm->size--;
if(nclistlength(seq) == 0) {nclistfree(seq); hm->table[offset] = NULL;}
@ -140,7 +143,8 @@ nchashget(NChashmap* hm, nchashid hash)
int
nchashlookup(NChashmap* hm, nchashid hash, void** valuep)
{
int i,offset,len;
int i;
size_t offset,len;
NClist* seq;
void** list;
@ -158,13 +162,13 @@ nchashlookup(NChashmap* hm, nchashid hash, void** valuep)
/* Return the ith pair; order is completely arbitrary*/
/* Can be expensive*/
int
nchashith(NChashmap* hm, size_t index, nchashid* hashp, void** elemp)
nchashith(NChashmap* hm, int index, nchashid* hashp, void** elemp)
{
size_t i;
int i;
if(hm == NULL) return FALSE;
for(i=0;i<hm->alloc;i++) {
NClist* seq = hm->table[i];
size_t len = nclistlength(seq) / 2;
int len = nclistlength(seq) / 2;
if(len == 0) continue;
if((index - len) < 0) {
if(hashp) *hashp = (nchashid)nclistget(seq,index*2);
@ -181,7 +185,7 @@ nchashith(NChashmap* hm, size_t index, nchashid* hashp, void** elemp)
int
nchashkeys(NChashmap* hm, nchashid** keylist)
{
size_t i,j,index;
int i,j,index;
nchashid* keys;
if(hm == NULL) return FALSE;
if(hm->size == 0) {

View File

@ -119,7 +119,7 @@ CdMonthDay(int *doy, CdTime *date)
date->month = 0;
for (i = 0; i < 12; i++) {
(date->month)++;
date->day = idoy;
date->day = (short)idoy;
if ((idoy -= ((date->timeType & Cd365) ? (mon_day_cnt[date->month-1]) : 30)) <= 0) {
return;
}
@ -190,7 +190,7 @@ Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime)
int daysInYear; /* days in non-leap year */
extern void CdMonthDay(int *doy, CdTime *date);
doy = (long) floor(etime / 24.) + 1;
doy = (int) floor(etime / 24.) + 1;
htime->hour = etime - (double) (doy - 1) * 24.;
/* Correct for goofy floor func on J90 */
@ -280,7 +280,7 @@ CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType,
delMonths = delMonths * nDel * delTime.count + bhtime.month - 1;
delYears = (delMonths >= 0 ? (delMonths/12) : (delMonths+1)/12 - 1);
ehtime.year = bhtime.year + delYears;
ehtime.month = delMonths - (12 * delYears) + 1;
ehtime.month = (short)(delMonths - (12 * delYears) + 1);
ehtime.day = 1;
ehtime.hour = 0.0;
ehtime.timeType = timeType;
@ -291,7 +291,7 @@ CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType,
Cdh2e(&ehtime,endEtm);
break;
case CdWeek: case CdDay: case CdHour: case CdMinute: case CdSecond:
delHours *= (nDel * delTime.count);
delHours = delHours * (double)(nDel * delTime.count);
*endEtm = begEtm + delHours;
break;
default: break;
@ -513,7 +513,7 @@ CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeT
range = (ehtime.month - bhtime.month);
if(range < 0) range += 12;
}
*nDel = abs(range)/delMonths;
*nDel = abs((int)range)/delMonths;
break;
case CdWeek: case CdDay: case CdHour: case CdMinute: case CdSecond:
delHours *= (double)delTime.count;
@ -532,7 +532,7 @@ CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeT
if(frange < 0.0 || frange >= hoursInYear)
frange -= hoursInYear * floor(frange/hoursInYear);
}
*nDel = (frange + 1.e-10*delHours)/delHours;
*nDel = (long)((frange + 1.e-10*delHours)/delHours);
break;
default: break;
}
@ -834,8 +834,12 @@ cdComp2Rel(cdCalenType timetype, cdCompTime comptime, char* relunits, double* re
if(!(timetype & cdStandardCal)){ /* Climatological time */
hoursInYear = (timetype & cd365Days) ? 8760. : (timetype & cdHasLeap) ? 8784. : 8640.;
/* Normalize delta to interval [0,hoursInYear) */
if(delta < 0.0 || delta >= hoursInYear)
delta -= hoursInYear * floor(delta/hoursInYear);
if(delta < 0.0 || delta >= hoursInYear) {
double down = ((double)delta)/((double)hoursInYear);
down = floor(down);
down = down * (double)hoursInYear;
delta = delta - down;
}
}
break;
case cdYear: case cdSeason: case cdMonth:
@ -1089,7 +1093,7 @@ cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time)
dtmp = 60.0 * (comptime.hour - (double)ihr);
imin = (int)dtmp;
sec = 60.0 * (dtmp - (double)imin);
isec = sec;
isec = (int)sec;
if(sec == isec)
if(isec == 0)

View File

@ -316,9 +316,9 @@ ncuriparse(const char* uri0, NCURI** durip)
/* concat suffix and prefix params */
if(prefixparams != NULL || suffixparams != NULL) {
size_t plen = prefixparams ? strlen(prefixparams) : 0;
size_t slen = suffixparams ? strlen(suffixparams) : 0;
size_t space = plen + slen + 1;
int plen = prefixparams ? strlen(prefixparams) : 0;
int slen = suffixparams ? strlen(suffixparams) : 0;
int space = plen + slen + 1;
/* add 1 for an extra ampersand if both are defined */
space++;
duri->params = (char*)malloc(space);
@ -397,7 +397,7 @@ ncurisetconstraints(NCURI* duri,const char* constraints)
proj = (char*) p;
select = strchr(proj,'&');
if(select != NULL) {
size_t plen = (select - proj);
size_t plen = (size_t)(select - proj);
if(plen == 0) {
proj = NULL;
} else {
@ -430,8 +430,8 @@ ncuribuild(NCURI* duri, const char* prefix, const char* suffix, int flags)
char* tmpfile;
char* tmpsuffix;
char* tmpquery;
int nparams = 0;
int paramslen = 0;
size_t nparams = 0;
size_t paramslen = 0;
/* if both are specified, prefix has priority */
int withsuffixparams = ((flags&NCURISUFFIXPARAMS)!=0
@ -580,7 +580,7 @@ ncuridecodeparams(NCURI* ncuri)
{
char* cp;
int i,c;
int nparams;
size_t nparams;
char* params;
char** plist;
@ -721,19 +721,19 @@ ncrshift1(char* p)
static char* hexchars = "0123456789abcdefABCDEF";
static void
toHex(int b, char hex[2])
toHex(unsigned int b, char hex[2])
{
hex[0] = hexchars[(b >> 4) & 0xff];
hex[1] = hexchars[(b) & 0xff];
}
static unsigned int
static int
fromHex(int c)
{
if(c >= '0' && c <= '9') return (c - '0');
if(c >= 'a' && c <= 'f') return (10 + (c - 'a'));
if(c >= 'A' && c <= 'F') return (10 + (c - 'A'));
if(c >= '0' && c <= '9') return (int) (c - '0');
if(c >= 'a' && c <= 'f') return (int) (10 + (c - 'a'));
if(c >= 'A' && c <= 'F') return (int) (10 + (c - 'A'));
return 0;
}
@ -767,7 +767,7 @@ ncuriencode(char* s, char* allowable)
while((c2=*a++)) {
if(c == c2) break;
}
if(c2) {*outptr++ = c;}
if(c2) {*outptr++ = (char)c;}
else {
char hex[2];
toHex(c,hex);
@ -807,7 +807,7 @@ ncuridecodeonly(char* s, char* only)
outptr = decoded;
inptr = s;
while((c = *inptr++)) {
while((c = (unsigned int)*inptr++)) {
if(c == '+' && only != NULL && strchr(only,'+') != NULL)
*outptr++ = ' ';
else if(c == '%') {
@ -819,11 +819,11 @@ ncuridecodeonly(char* s, char* only)
int xc = (fromHex(inptr[0]) << 4) | (fromHex(inptr[1]));
if(only == NULL || strchr(only,xc) != NULL) {
inptr += 2; /* decode it */
c = xc;
c = (unsigned int)xc;
}
}
}
*outptr++ = c;
*outptr++ = (char)c;
}
*outptr = EOFCHAR;
return decoded;