Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d3462dfc
Commit
d3462dfc
authored
Jan 19, 2011
by
James Bowman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#674, fix leaks in CreateHist
parent
4b8425db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
cv.cpp
modules/python/cv.cpp
+39
-4
leak3.py
tests/python/leak3.py
+3
-1
No files found.
modules/python/cv.cpp
View file @
d3462dfc
...
...
@@ -2905,15 +2905,50 @@ static PyObject *fromarray(PyObject *o, int allowND)
}
#endif
class
ranges
{
public
:
Py_ssize_t
len
;
float
**
rr
;
ranges
()
{
len
=
0
;
rr
=
NULL
;
}
int
fromobj
(
PyObject
*
o
,
const
char
*
name
=
"no_name"
)
{
PyObject
*
fi
=
PySequence_Fast
(
o
,
name
);
if
(
fi
==
NULL
)
return
0
;
len
=
PySequence_Fast_GET_SIZE
(
fi
);
rr
=
new
float
*
[
len
];
for
(
Py_ssize_t
i
=
0
;
i
<
len
;
i
++
)
{
PyObject
*
item
=
PySequence_Fast_GET_ITEM
(
fi
,
i
);
floats
ff
;
if
(
!
convert_to_floats
(
item
,
&
ff
))
return
0
;
rr
[
i
]
=
ff
.
f
;
}
Py_DECREF
(
fi
);
return
1
;
}
~
ranges
()
{
for
(
Py_ssize_t
i
=
0
;
i
<
len
;
i
++
)
delete
rr
[
i
];
delete
rr
;
}
};
static
int
ranges_converter
(
PyObject
*
o
,
ranges
*
dst
)
{
return
dst
->
fromobj
(
o
);
}
static
PyObject
*
pycvCreateHist
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
const
char
*
keywords
[]
=
{
"dims"
,
"type"
,
"ranges"
,
"uniform"
,
NULL
};
PyObject
*
dims
;
int
type
;
float
**
ranges
=
NULL
;
int
uniform
=
1
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"Oi|O&i"
,
(
char
**
)
keywords
,
&
dims
,
&
type
,
convert_to_floatPTRPTR
,
(
void
*
)
&
ranges
,
&
uniform
))
{
ranges
r
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"Oi|O&i"
,
(
char
**
)
keywords
,
&
dims
,
&
type
,
ranges_converter
,
(
void
*
)
&
r
,
&
uniform
))
{
return
NULL
;
}
cvhistogram_t
*
h
=
PyObject_NEW
(
cvhistogram_t
,
&
cvhistogram_Type
);
...
...
@@ -2927,7 +2962,7 @@ static PyObject *pycvCreateHist(PyObject *self, PyObject *args, PyObject *kw)
if
(
!
convert_to_CvArr
(
h
->
bins
,
&
(
h
->
h
.
bins
),
"bins"
))
return
NULL
;
ERRWRAP
(
cvSetHistBinRanges
(
&
(
h
->
h
),
r
anges
,
uniform
));
ERRWRAP
(
cvSetHistBinRanges
(
&
(
h
->
h
),
r
.
rr
,
uniform
));
return
(
PyObject
*
)
h
;
}
...
...
tests/python/leak3.py
View file @
d3462dfc
import
cv
import
math
import
time
while
True
:
cv
.
CreateHist
([
40
],
cv
.
CV_HIST_ARRAY
,
[[
0
,
255
]],
1
)
h
=
cv
.
CreateHist
([
40
],
cv
.
CV_HIST_ARRAY
,
[[
0
,
255
]],
1
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment