Skip to content

Commit 3341382

Browse files
Use size_t instead of long for array value index
1 parent 2fc4040 commit 3341382

3 files changed

Lines changed: 328 additions & 261 deletions

File tree

src/interface/value.i

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ KEEP_REFERENCE(const Exiv2::Value&)
7878
}
7979

8080
// for indexing multi-value values, assumes arg1 points to self
81-
%typemap(check) long idx %{
82-
if ($1 < 0 || $1 >= static_cast< long >(arg1->count())) {
81+
%typemap(check) size_t idx %{
82+
if ($1 < 0 || $1 >= static_cast< size_t >(arg1->count())) {
8383
PyErr_Format(PyExc_IndexError, "index %d out of range", $1);
8484
SWIG_fail;
8585
}
8686
%}
8787
// for indexing single-value values, assumes arg1 points to self
88-
%typemap(check) long single_idx %{
88+
%typemap(check) size_t single_idx %{
8989
if ($1 < 0 || $1 >= (arg1->count() ? 1 : 0)) {
9090
PyErr_Format(PyExc_IndexError, "index %d out of range", $1);
9191
SWIG_fail;
@@ -318,10 +318,10 @@ VALUE_SUBCLASS(Exiv2::ValueType<item_type>, type_name)
318318
result->value_ = value;
319319
return result;
320320
}
321-
item_type __getitem__(long idx) {
321+
item_type __getitem__(size_t idx) {
322322
return $self->value_[idx];
323323
}
324-
void __setitem__(long idx, const item_type* INPUT) {
324+
void __setitem__(size_t idx, const item_type* INPUT) {
325325
if (INPUT)
326326
$self->value_[idx] = *INPUT;
327327
else

0 commit comments

Comments
 (0)