Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
010b8601
Commit
010b8601
authored
Feb 06, 2007
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix refcounting bugs related to CONVERT_BINOP.
parent
2c1e13fc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
Objects/longobject.c
Objects/longobject.c
+26
-8
No files found.
Objects/longobject.c
View file @
010b8601
...
...
@@ -2147,8 +2147,12 @@ static PyObject *
long_richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op
)
{
PyLongObject
*
a
,
*
b
;
PyObject
*
result
;
CONVERT_BINOP
((
PyObject
*
)
self
,
(
PyObject
*
)
other
,
&
a
,
&
b
);
return
Py_CmpToRich
(
op
,
long_compare
(
a
,
b
));
result
=
Py_CmpToRich
(
op
,
long_compare
(
a
,
b
));
Py_DECREF
(
a
);
Py_DECREF
(
b
);
return
result
;
}
static
long
...
...
@@ -2283,9 +2287,13 @@ long_add(PyLongObject *v, PyLongObject *w)
CONVERT_BINOP
((
PyObject
*
)
v
,
(
PyObject
*
)
w
,
&
a
,
&
b
);
if
(
ABS
(
a
->
ob_size
)
<=
1
&&
ABS
(
b
->
ob_size
)
<=
1
)
return
PyInt_FromLong
(
MEDIUM_VALUE
(
a
)
+
if
(
ABS
(
a
->
ob_size
)
<=
1
&&
ABS
(
b
->
ob_size
)
<=
1
)
{
PyObject
*
result
=
PyInt_FromLong
(
MEDIUM_VALUE
(
a
)
+
MEDIUM_VALUE
(
b
));
Py_DECREF
(
a
);
Py_DECREF
(
b
);
return
result
;
}
if
(
a
->
ob_size
<
0
)
{
if
(
b
->
ob_size
<
0
)
{
z
=
x_add
(
a
,
b
);
...
...
@@ -2313,8 +2321,13 @@ long_sub(PyLongObject *v, PyLongObject *w)
CONVERT_BINOP
((
PyObject
*
)
v
,
(
PyObject
*
)
w
,
&
a
,
&
b
);
if
(
ABS
(
a
->
ob_size
)
<=
1
&&
ABS
(
b
->
ob_size
)
<=
1
)
return
PyLong_FromLong
(
MEDIUM_VALUE
(
a
)
-
MEDIUM_VALUE
(
b
));
if
(
ABS
(
a
->
ob_size
)
<=
1
&&
ABS
(
b
->
ob_size
)
<=
1
)
{
PyObject
*
r
;
r
=
PyLong_FromLong
(
MEDIUM_VALUE
(
a
)
-
MEDIUM_VALUE
(
b
));
Py_DECREF
(
a
);
Py_DECREF
(
b
);
return
r
;
}
if
(
a
->
ob_size
<
0
)
{
if
(
b
->
ob_size
<
0
)
z
=
x_sub
(
a
,
b
);
...
...
@@ -2744,8 +2757,13 @@ long_mul(PyLongObject *v, PyLongObject *w)
return
Py_NotImplemented
;
}
if
(
ABS
(
v
->
ob_size
)
<=
1
&&
ABS
(
w
->
ob_size
)
<=
1
)
return
PyLong_FromLong
(
MEDIUM_VALUE
(
v
)
*
MEDIUM_VALUE
(
w
));
if
(
ABS
(
v
->
ob_size
)
<=
1
&&
ABS
(
w
->
ob_size
)
<=
1
)
{
PyObject
*
r
;
r
=
PyLong_FromLong
(
MEDIUM_VALUE
(
v
)
*
MEDIUM_VALUE
(
w
));
Py_DECREF
(
a
);
Py_DECREF
(
b
);
return
r
;
}
z
=
k_mul
(
a
,
b
);
/* Negate if exactly one of the inputs is negative. */
...
...
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