[Insight-users] Image offset is giving bad pointer for large datasets (7Gb)

Mike Jackson mike.jackson at bluequartz.net
Sat Jul 11 08:50:46 EDT 2009


I think the only thing I have against using ptrdiff_t is that it
doesn't describe exactly what you are wanting in a type. ptrdiff_t is
the result of subtraction between two _pointers_. Is OffsetValueType
really a Pointer or an index into an array? I think if programmers
started digging when debugging and saw ptrdiff_t then that might be
confusing to them as they might start thinking that they can cast an
OffsetValueType to a pointer and start doing pointer manipulations on
it.
   It seems to me that OffsetValueType is just that, a _value_, and
not a pointer. Also, do we fully understand how ptrdiff_t is defined
on all the platforms that ITK runs on? Can we be sure we take that
into account properly? In comparison we know _exactly_ how it behaves
because we would be using either "int" or "long long int" which also
has the advantage of describing exactly what we need, a plain old
signed integer. Again, when new ITK programmers start digging to find
out what OffsetValueType and come up with a plain old integer there
most likely will not be any misunderstanding about the type.

Mike Jackson

On Sat, Jul 11, 2009 at 7:02 AM, Luis Ibanez<luis.ibanez at kitware.com> wrote:
>
> What's wrong with using :     ptrdiff_t   ?
>
>
>        Luis
>
>
> -----------------------------------------------------------
> On Fri, Jul 10, 2009 at 8:34 PM, Mike Jackson <mike.jackson at bluequartz.net>
> wrote:
>>
>> Probably should have googled that first. Seems to be a POSIX extension
>> so probably isn't that portable.
>>
>>  From an earlier email:
>> ------
>> On recent realization:
>>
>>             "size_t"    is unsigned       :-/
>>
>> and we need the OffsetValueType to be signed,
>> since we use it to compute differences...
>> ------
>> so why doesn't ITK just define it to int or long long int depending on
>> the size of size_t? That test could be run during CMake time like all
>> the others?
>>
>> #if size_of_size_t == 4
>> typedef signed int OffsetValueType;
>> #elif size_of_size_t == 8
>> typedef signed long long int OffsetValueType;
>> #endif
>>
>> Of course we would probably want to use the predefined 64 bit type
>> that the ITK/CMake tests come up with: __int64, _int64_t, int64_t or
>> whatever they are..
>>
>> Just my thoughts?
>> Mike
>>
>> On Fri, Jul 10, 2009 at 8:23 PM, Mike
>> Jackson<mike.jackson at bluequartz.net> wrote:
>> > Is there a "ssize_t" type? Or is that some contrived type on some of
>> > the projects that I work on?
>> >
>> > Mike
>> >
>> > On Fri, Jul 10, 2009 at 6:29 PM, Luis Ibanez<luis.ibanez at kitware.com>
>> > wrote:
>> >>
>> >> On recent realization:
>> >>
>> >>              "size_t"    is unsigned       :-/
>> >>
>> >> and we need the OffsetValueType to be signed,
>> >> since we use it to compute differences...
>> >>
>> >> It seems that what we need is the type
>> >>
>> >>                         "ptrdiff_t"
>> >>
>> >> which is supposed to represent the differences
>> >> between two pointers, and therefore should be
>> >> capable of measuring distances between any
>> >> two locations in memory.
>> >>
>> >> I'm now rerunning the Experimental with
>> >> "ptrdiff_t" instead of "size_t".
>> >>
>> >>
>> > Luis
>> >
>


More information about the Insight-users mailing list