diff --git a/Makefile.am b/Makefile.am index e0479b0..2ba1078 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,7 @@ check_PROGRAMS = test_ics1 \ test_gzip \ test_strides \ test_strides2 \ + test_strides3 \ test_metadata \ test_history @@ -57,6 +58,7 @@ test_compress_SOURCES = test_compress.c test_gzip_SOURCES = test_gzip.c test_strides_SOURCES = test_strides.c test_strides2_SOURCES = test_strides2.c +test_strides3_SOURCES = test_strides3.c test_metadata_SOURCES = test_metadata.c test_history_SOURCES = test_history.c @@ -67,6 +69,7 @@ test_compress_LDADD = libics.la test_gzip_LDADD = libics.la test_strides_LDADD = libics.la test_strides2_LDADD = libics.la +test_strides3_LDADD = libics.la test_metadata_LDADD = libics.la test_history_LDADD = libics.la @@ -77,6 +80,7 @@ TESTS = test_ics1.sh \ test_gzip.sh \ test_strides.sh \ test_strides2.sh \ + test_strides3.sh \ test_metadata.sh \ test_history.sh diff --git a/Makefile.in b/Makefile.in index 04ca944..9499d83 100644 --- a/Makefile.in +++ b/Makefile.in @@ -103,7 +103,7 @@ build_triplet = @build@ host_triplet = @host@ check_PROGRAMS = test_ics1$(EXEEXT) test_ics2a$(EXEEXT) \ test_ics2b$(EXEEXT) test_compress$(EXEEXT) test_gzip$(EXEEXT) \ - test_strides$(EXEEXT) test_strides2$(EXEEXT) \ + test_strides$(EXEEXT) test_strides2$(EXEEXT) test_strides3$(EXEEXT) \ test_metadata$(EXEEXT) test_history$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -159,7 +159,7 @@ libics_la_OBJECTS = $(am_libics_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent -am__v_lt_1 = +am__v_lt_1 = libics_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libics_la_LDFLAGS) $(LDFLAGS) -o $@ @@ -190,6 +190,9 @@ test_strides_DEPENDENCIES = libics.la am_test_strides2_OBJECTS = test_strides2.$(OBJEXT) test_strides2_OBJECTS = $(am_test_strides2_OBJECTS) test_strides2_DEPENDENCIES = libics.la +am_test_strides3_OBJECTS = test_strides3.$(OBJEXT) +test_strides3_OBJECTS = $(am_test_strides3_OBJECTS) +test_strides3_DEPENDENCIES = libics.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -197,11 +200,11 @@ am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = +am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ -am__v_at_1 = +am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -215,7 +218,7 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = +am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -223,17 +226,17 @@ LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = +am__v_CCLD_1 = SOURCES = $(libics_la_SOURCES) $(test_compress_SOURCES) \ $(test_gzip_SOURCES) $(test_history_SOURCES) \ $(test_ics1_SOURCES) $(test_ics2a_SOURCES) \ $(test_ics2b_SOURCES) $(test_metadata_SOURCES) \ - $(test_strides_SOURCES) $(test_strides2_SOURCES) + $(test_strides_SOURCES) $(test_strides2_SOURCES) $(test_strides3_SOURCES) DIST_SOURCES = $(libics_la_SOURCES) $(test_compress_SOURCES) \ $(test_gzip_SOURCES) $(test_history_SOURCES) \ $(test_ics1_SOURCES) $(test_ics2a_SOURCES) \ $(test_ics2b_SOURCES) $(test_metadata_SOURCES) \ - $(test_strides_SOURCES) $(test_strides2_SOURCES) + $(test_strides_SOURCES) $(test_strides2_SOURCES) $(test_strides3_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -613,6 +616,7 @@ test_compress_SOURCES = test_compress.c test_gzip_SOURCES = test_gzip.c test_strides_SOURCES = test_strides.c test_strides2_SOURCES = test_strides2.c +test_strides3_SOURCES = test_strides3.c test_metadata_SOURCES = test_metadata.c test_history_SOURCES = test_history.c test_ics1_LDADD = libics.la @@ -622,6 +626,7 @@ test_compress_LDADD = libics.la test_gzip_LDADD = libics.la test_strides_LDADD = libics.la test_strides2_LDADD = libics.la +test_strides3_LDADD = libics.la test_metadata_LDADD = libics.la test_history_LDADD = libics.la TESTS = test_ics1.sh \ @@ -631,6 +636,7 @@ TESTS = test_ics1.sh \ test_gzip.sh \ test_strides.sh \ test_strides2.sh \ + test_strides3.sh \ test_metadata.sh \ test_history.sh @@ -721,7 +727,7 @@ config.h: stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h -$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ @@ -772,7 +778,7 @@ clean-libLTLIBRARIES: rm -f $${locs}; \ } -libics.la: $(libics_la_OBJECTS) $(libics_la_DEPENDENCIES) $(EXTRA_libics_la_DEPENDENCIES) +libics.la: $(libics_la_OBJECTS) $(libics_la_DEPENDENCIES) $(EXTRA_libics_la_DEPENDENCIES) $(AM_V_CCLD)$(libics_la_LINK) -rpath $(libdir) $(libics_la_OBJECTS) $(libics_la_LIBADD) $(LIBS) clean-checkPROGRAMS: @@ -784,42 +790,46 @@ clean-checkPROGRAMS: echo " rm -f" $$list; \ rm -f $$list -test_compress$(EXEEXT): $(test_compress_OBJECTS) $(test_compress_DEPENDENCIES) $(EXTRA_test_compress_DEPENDENCIES) +test_compress$(EXEEXT): $(test_compress_OBJECTS) $(test_compress_DEPENDENCIES) $(EXTRA_test_compress_DEPENDENCIES) @rm -f test_compress$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_compress_OBJECTS) $(test_compress_LDADD) $(LIBS) -test_gzip$(EXEEXT): $(test_gzip_OBJECTS) $(test_gzip_DEPENDENCIES) $(EXTRA_test_gzip_DEPENDENCIES) +test_gzip$(EXEEXT): $(test_gzip_OBJECTS) $(test_gzip_DEPENDENCIES) $(EXTRA_test_gzip_DEPENDENCIES) @rm -f test_gzip$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_gzip_OBJECTS) $(test_gzip_LDADD) $(LIBS) -test_history$(EXEEXT): $(test_history_OBJECTS) $(test_history_DEPENDENCIES) $(EXTRA_test_history_DEPENDENCIES) +test_history$(EXEEXT): $(test_history_OBJECTS) $(test_history_DEPENDENCIES) $(EXTRA_test_history_DEPENDENCIES) @rm -f test_history$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_history_OBJECTS) $(test_history_LDADD) $(LIBS) -test_ics1$(EXEEXT): $(test_ics1_OBJECTS) $(test_ics1_DEPENDENCIES) $(EXTRA_test_ics1_DEPENDENCIES) +test_ics1$(EXEEXT): $(test_ics1_OBJECTS) $(test_ics1_DEPENDENCIES) $(EXTRA_test_ics1_DEPENDENCIES) @rm -f test_ics1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_ics1_OBJECTS) $(test_ics1_LDADD) $(LIBS) -test_ics2a$(EXEEXT): $(test_ics2a_OBJECTS) $(test_ics2a_DEPENDENCIES) $(EXTRA_test_ics2a_DEPENDENCIES) +test_ics2a$(EXEEXT): $(test_ics2a_OBJECTS) $(test_ics2a_DEPENDENCIES) $(EXTRA_test_ics2a_DEPENDENCIES) @rm -f test_ics2a$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_ics2a_OBJECTS) $(test_ics2a_LDADD) $(LIBS) -test_ics2b$(EXEEXT): $(test_ics2b_OBJECTS) $(test_ics2b_DEPENDENCIES) $(EXTRA_test_ics2b_DEPENDENCIES) +test_ics2b$(EXEEXT): $(test_ics2b_OBJECTS) $(test_ics2b_DEPENDENCIES) $(EXTRA_test_ics2b_DEPENDENCIES) @rm -f test_ics2b$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_ics2b_OBJECTS) $(test_ics2b_LDADD) $(LIBS) -test_metadata$(EXEEXT): $(test_metadata_OBJECTS) $(test_metadata_DEPENDENCIES) $(EXTRA_test_metadata_DEPENDENCIES) +test_metadata$(EXEEXT): $(test_metadata_OBJECTS) $(test_metadata_DEPENDENCIES) $(EXTRA_test_metadata_DEPENDENCIES) @rm -f test_metadata$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_metadata_OBJECTS) $(test_metadata_LDADD) $(LIBS) -test_strides$(EXEEXT): $(test_strides_OBJECTS) $(test_strides_DEPENDENCIES) $(EXTRA_test_strides_DEPENDENCIES) +test_strides$(EXEEXT): $(test_strides_OBJECTS) $(test_strides_DEPENDENCIES) $(EXTRA_test_strides_DEPENDENCIES) @rm -f test_strides$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_strides_OBJECTS) $(test_strides_LDADD) $(LIBS) -test_strides2$(EXEEXT): $(test_strides2_OBJECTS) $(test_strides2_DEPENDENCIES) $(EXTRA_test_strides2_DEPENDENCIES) +test_strides2$(EXEEXT): $(test_strides2_OBJECTS) $(test_strides2_DEPENDENCIES) $(EXTRA_test_strides2_DEPENDENCIES) @rm -f test_strides2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_strides2_OBJECTS) $(test_strides2_LDADD) $(LIBS) +test_strides3$(EXEEXT): $(test_strides3_OBJECTS) $(test_strides3_DEPENDENCIES) $(EXTRA_test_strides3_DEPENDENCIES) + @rm -f test_strides3$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_strides3_OBJECTS) $(test_strides3_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -847,6 +857,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_metadata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_strides.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_strides2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_strides3.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -1148,6 +1159,13 @@ test_strides2.sh.log: test_strides2.sh --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +test_strides3.sh.log: test_strides3.sh + @p='test_strides3.sh'; \ + b='test_strides3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) test_metadata.sh.log: test_metadata.sh @p='test_metadata.sh'; \ b='test_metadata.sh'; \ diff --git a/docs/Ics_Header.html b/docs/Ics_Header.html index 10a8607..981f455 100644 --- a/docs/Ics_Header.html +++ b/docs/Ics_Header.html @@ -152,7 +152,7 @@
type: - size_t const*
+ ptrdiff_t const*access: IcsSetDataWithStrides.
diff --git a/docs/TopLevelFunctions.html b/docs/TopLevelFunctions.html index 3e551d7..1800a9f 100644 --- a/docs/TopLevelFunctions.html +++ b/docs/TopLevelFunctions.html @@ -338,7 +338,7 @@This function does currently not work when the data is compressed with IcsCompr_compress.
+The parameter n is ignored.
+errors: IcsErr_Alloc, IcsErr_BitsVsSizeConfl, @@ -582,7 +584,7 @@
The parameter n is ignored.
+errors:
IcsErr_DuplicateData,
IcsErr_FSizeConflict,
diff --git a/libics.h b/libics.h
index 13dc5bc..cb104d7 100644
--- a/libics.h
+++ b/libics.h
@@ -207,7 +207,7 @@ typedef struct _ICS {
/* Size of the data buffer: */
size_t dataLength;
/* Pixel strides (writing only): */
- const size_t *dataStrides;
+ const ptrdiff_t *dataStrides;
/* '.ics' path/filename: */
char filename[ICS_MAXPATHLEN];
/* Number of elements in each dim: */
@@ -527,11 +527,11 @@ ICSEXPORT Ics_Error IcsGetROIData(ICS *ics,
/* Read the image from an ICS file into a sub-block of a memory block. To use
the defaults in one of the parameters, set the pointer to NULL. Only valid if
reading. */
-ICSEXPORT Ics_Error IcsGetDataWithStrides(ICS *ics,
- void *dest,
- size_t n,
- const size_t *stride,
- int nDims);
+ICSEXPORT Ics_Error IcsGetDataWithStrides(ICS *ics,
+ void *dest,
+ size_t n, // ignored
+ const ptrdiff_t *stride,
+ int nDims);
/* Read a portion of the image data from an ICS file. Only valid if reading. */
@@ -562,11 +562,11 @@ ICSEXPORT Ics_Error IcsSetData(ICS *ics,
/* Set the image data for an ICS image. The pointer to this data must be
accessible until IcsClose has been called. Only valid if writing. */
-ICSEXPORT Ics_Error IcsSetDataWithStrides(ICS *ics,
- const void *src,
- size_t n,
- const size_t *strides,
- int nDims);
+ICSEXPORT Ics_Error IcsSetDataWithStrides(ICS *ics,
+ const void *src,
+ size_t n,
+ const ptrdiff_t *strides,
+ int nDims);
/* Set the image source parameter for an ICS version 2.0 file. Only valid if
writing. */
diff --git a/libics_binary.c b/libics_binary.c
index 7cfef74..2a830a4 100644
--- a/libics_binary.c
+++ b/libics_binary.c
@@ -64,12 +64,12 @@
/* Write uncompressed data, with strides. */
-Ics_Error IcsWritePlainWithStrides(const void *src,
- const size_t *dim,
- const size_t *stride,
- int nDims,
- int nBytes,
- FILE *file)
+Ics_Error IcsWritePlainWithStrides(const void *src,
+ const size_t *dim,
+ const ptrdiff_t *stride,
+ int nDims,
+ int nBytes,
+ FILE *file)
{
ICSINIT;
size_t curpos[ICS_MAXDIM];
@@ -84,7 +84,7 @@ Ics_Error IcsWritePlainWithStrides(const void *src,
while (1) {
data = (char const*)src;
for (i = 1; i < nDims; i++) {
- data += curpos[i] * stride[i] * nBytes;
+ data += (ptrdiff_t)curpos[i] * stride[i] * nBytes;
}
if (stride[0] == 1) {
if (fwrite(data, nBytes, dim[0], file) != dim[0]) {
diff --git a/libics_gzip.c b/libics_gzip.c
index a8233f8..e3d9ce2 100644
--- a/libics_gzip.c
+++ b/libics_gzip.c
@@ -207,13 +207,13 @@ Ics_Error IcsWriteZip(const void *inBuf,
/* Write ZIP compressed data, with strides. */
-Ics_Error IcsWriteZipWithStrides(const void *src,
- const size_t *dim,
- const size_t *stride,
- int nDims,
- int nBytes,
- FILE *file,
- int level)
+Ics_Error IcsWriteZipWithStrides(const void *src,
+ const size_t *dim,
+ const ptrdiff_t *stride,
+ int nDims,
+ int nBytes,
+ FILE *file,
+ int level)
{
#ifdef ICS_ZLIB
ICSINIT;
@@ -277,7 +277,7 @@ Ics_Error IcsWriteZipWithStrides(const void *src,
while (1) {
data = (char const*)src;
for (i = 1; i < nDims; i++) { /* curPos[0]==0 here */
- data += curPos[i] * stride[i] * nBytes;
+ data += (ptrdiff_t)curPos[i] * stride[i] * nBytes;
}
/* Get data line */
if (contiguousLine) {
diff --git a/libics_intern.h b/libics_intern.h
index 1a31b2a..df209f1 100644
--- a/libics_intern.h
+++ b/libics_intern.h
@@ -246,12 +246,12 @@ Ics_Error IcsInternAddHistory(Ics_Header *ics,
void IcsFillByteOrder(int bytes,
int machineByteOrder[ICS_MAX_IMEL_SIZE]);
-Ics_Error IcsWritePlainWithStrides(const void *src,
- const size_t *dim,
- const size_t *stride,
- int nDims,
- int nBytes,
- FILE *file);
+Ics_Error IcsWritePlainWithStrides(const void *src,
+ const size_t *dim,
+ const ptrdiff_t *stride,
+ int nDims,
+ int nBytes,
+ FILE *file);
Ics_Error IcsCopyIds(const char *infilename,
size_t inoffset,
@@ -263,13 +263,13 @@ Ics_Error IcsWriteZip(const void *src,
FILE *fp,
int CompLevel);
-Ics_Error IcsWriteZipWithStrides(const void *src,
- const size_t *dim,
- const size_t *stride,
- int nDims,
- int nBytes,
- FILE *file,
- int level);
+Ics_Error IcsWriteZipWithStrides(const void *src,
+ const size_t *dim,
+ const ptrdiff_t *stride,
+ int nDims,
+ int nBytes,
+ FILE *file,
+ int level);
Ics_Error IcsOpenZip(Ics_Header *IcsStruct);
diff --git a/libics_top.c b/libics_top.c
index 51c197a..6110b21 100644
--- a/libics_top.c
+++ b/libics_top.c
@@ -534,28 +534,28 @@ Ics_Error IcsGetROIData(ICS *ics,
/* Read the image data into a region of your buffer. */
-Ics_Error IcsGetDataWithStrides(ICS *ics,
- void *destPtr,
- size_t n,
- const size_t *stridePtr,
- int nDims)
+Ics_Error IcsGetDataWithStrides(ICS *ics,
+ void *destPtr,
+ size_t n, // ignored
+ const ptrdiff_t *stridePtr,
+ int nDims)
{
ICSINIT;
- int i, p;
- size_t j;
- size_t imelSize, lastpixel, bufSize;
- size_t curPos[ICS_MAXDIM];
- size_t b_stride[ICS_MAXDIM];
- size_t const *stride;
- char *buf;
- char *dest = (char*)destPtr;
- char *out;
+ int i, p;
+ size_t j;
+ size_t imelSize, bufSize;
+ size_t curPos[ICS_MAXDIM];
+ ptrdiff_t b_stride[ICS_MAXDIM];
+ ptrdiff_t const *stride;
+ char *buf;
+ char *dest = (char*)destPtr;
+ char *out;
if ((ics == NULL) || (ics->fileMode == IcsFileMode_write))
return IcsErr_NotValidAction;
- if ((n == 0) ||(dest == NULL)) return IcsErr_Ok;
+ if (dest == NULL) return IcsErr_Ok;
p = ics->dimensions;
if (nDims != p) return IcsErr_IllParameter;
if (stridePtr != NULL) {
@@ -563,23 +563,18 @@ Ics_Error IcsGetDataWithStrides(ICS *ics,
} else {
b_stride[0] = 1;
for (i = 1; i < p; i++) {
- b_stride[i] = b_stride[i - 1] * ics->dim[i - 1].size;
+ b_stride[i] = b_stride[i - 1] * (ptrdiff_t)ics->dim[i - 1].size;
}
stride = b_stride;
}
imelSize = IcsGetBytesPerSample(ics);
- lastpixel = 0;
- for (i = 0; i < p; i++) {
- lastpixel +=(ics->dim[i].size - 1) * stride[i];
- }
- if (lastpixel * imelSize > n) return IcsErr_IllParameter;
error = IcsOpenIds(ics);
if (error) return error;
- bufSize = imelSize*ics->dim[0].size;
- if (stride[0] > 1) {
+ bufSize = imelSize * ics->dim[0].size;
+ if (stride[0] != 1) {
/* We read a line in a buffer, and then copy the imels to dest */
- buf =(char*)malloc(bufSize);
+ buf = (char*)malloc(bufSize);
if (buf == NULL) return IcsErr_Alloc;
for (i = 0; i < p; i++) {
curPos[i] = 0;
@@ -587,7 +582,7 @@ Ics_Error IcsGetDataWithStrides(ICS *ics,
while (1) {
out = dest;
for (i = 1; i < p; i++) {
- out += curPos[i] * stride[i] * imelSize;
+ out += (ptrdiff_t)curPos[i] * stride[i] * (ptrdiff_t)imelSize;
}
if (!error) error = IcsReadIdsBlock(ics, buf, bufSize);
if (error != IcsErr_Ok) {
@@ -595,7 +590,7 @@ Ics_Error IcsGetDataWithStrides(ICS *ics,
}
for (j = 0; j < ics->dim[0].size; j++) {
memcpy(out, buf + j * imelSize, imelSize);
- out += stride[0]*imelSize;
+ out += stride[0] * (ptrdiff_t)imelSize;
}
for (i = 1; i < p; i++) {
curPos[i]++;
@@ -617,7 +612,7 @@ Ics_Error IcsGetDataWithStrides(ICS *ics,
while (1) {
out = dest;
for (i = 1; i < p; i++) {
- out += curPos[i] * stride[i] * imelSize;
+ out += (ptrdiff_t)curPos[i] * stride[i] * (ptrdiff_t)imelSize;
}
if (!error) error = IcsReadIdsBlock(ics, out, bufSize);
if (error != IcsErr_Ok) {
@@ -674,15 +669,13 @@ Ics_Error IcsSetData(ICS *ics,
dimension. Use this is your image data is not in one contiguous block or you
want to swap some dimensions in the file. nDims is the length of the strides
array and should match the dimensionality previously given. */
-Ics_Error IcsSetDataWithStrides(ICS *ics,
- const void *src,
- size_t n,
- const size_t *strides,
- int nDims)
+Ics_Error IcsSetDataWithStrides(ICS *ics,
+ const void *src,
+ size_t n,
+ const ptrdiff_t *strides,
+ int nDims)
{
ICSINIT;
- size_t lastpixel;
- int i;
if ((ics == NULL) || (ics->fileMode != IcsFileMode_write))
@@ -692,15 +685,6 @@ Ics_Error IcsSetDataWithStrides(ICS *ics,
if (ics->data != NULL) return IcsErr_DuplicateData;
if (ics->dimensions == 0) return IcsErr_NoLayout;
if (nDims != ics->dimensions) return IcsErr_IllParameter;
- lastpixel = 0;
- for (i = 0; i < nDims; i++) {
- lastpixel +=(ics->dim[i].size-1) * strides[i];
- }
- if (lastpixel * IcsGetDataTypeSize(ics->imel.dataType) > n)
- return IcsErr_IllParameter;
- if (n != IcsGetDataSize(ics)) {
- error = IcsErr_FSizeConflict;
- }
ics->data = src;
ics->dataLength = n;
ics->dataStrides = strides;
diff --git a/test_strides.c b/test_strides.c
index b696476..733b33c 100644
--- a/test_strides.c
+++ b/test_strides.c
@@ -9,7 +9,7 @@ int main(int argc, const char* argv[]) {
int ndims;
size_t dims[ICS_MAXDIM];
size_t bufsize;
- size_t strides[3];
+ ptrdiff_t strides[3];
void* buf1;
void* buf2;
void* buf3;
@@ -30,8 +30,8 @@ int main(int argc, const char* argv[]) {
}
IcsGetLayout(ip, &dt, &ndims, dims);
strides[0] = 1;
- strides[1] = dims[0]*dims[2];
- strides[2] = dims[0];
+ strides[1] = (ptrdiff_t)(dims[0]*dims[2]);
+ strides[2] = (ptrdiff_t)dims[0];
bufsize = IcsGetDataSize(ip);
buf1 = malloc(bufsize);
if (buf1 == NULL) {
diff --git a/test_strides2.c b/test_strides2.c
index 1be9773..0e4560d 100644
--- a/test_strides2.c
+++ b/test_strides2.c
@@ -9,7 +9,7 @@ int main(int argc, const char* argv[]) {
int ndims;
size_t dims[ICS_MAXDIM];
size_t bufsize;
- size_t strides[3];
+ ptrdiff_t strides[3];
void* buf1;
void* buf2;
void* buf3;
@@ -29,9 +29,9 @@ int main(int argc, const char* argv[]) {
exit(-1);
}
IcsGetLayout(ip, &dt, &ndims, dims);
- strides[0] = dims[1]*2;
+ strides[0] = (ptrdiff_t)(dims[1]*2);
strides[1] = 2;
- strides[2] = dims[0]*dims[1]*2;
+ strides[2] = (ptrdiff_t)(dims[0]*dims[1]*2);
bufsize = IcsGetDataSize(ip);
buf1 = malloc(bufsize);
if (buf1 == NULL) {
diff --git a/test_strides2.sh b/test_strides2.sh
index aa3a0a5..55445a1 100755
--- a/test_strides2.sh
+++ b/test_strides2.sh
@@ -1 +1 @@
-./test_strides2 $srcdir/test/testim.ics result_s.ics
+./test_strides2 $srcdir/test/testim.ics result_s2.ics
diff --git a/test_strides3.c b/test_strides3.c
new file mode 100644
index 0000000..8bdd938
--- /dev/null
+++ b/test_strides3.c
@@ -0,0 +1,118 @@
+#include