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
e7c05323
Commit
e7c05323
authored
Jun 27, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sizeof(char) is 1, by definition, so get rid of that expression in
places it's just noise.
parent
ef82d2fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
17 deletions
+11
-17
Modules/cStringIO.c
Modules/cStringIO.c
+4
-5
Objects/stringobject.c
Objects/stringobject.c
+7
-12
No files found.
Modules/cStringIO.c
View file @
e7c05323
...
...
@@ -336,8 +336,8 @@ O_seek(Oobject *self, PyObject *args) {
if
(
position
>
self
->
buf_size
)
{
self
->
buf_size
*=
2
;
if
(
self
->
buf_size
<=
position
)
self
->
buf_size
=
position
+
1
;
UNLESS
(
self
->
buf
=
(
char
*
)
realloc
(
self
->
buf
,
self
->
buf_size
*
sizeof
(
char
)
))
{
UNLESS
(
self
->
buf
=
(
char
*
)
realloc
(
self
->
buf
,
self
->
buf_size
))
{
self
->
buf_size
=
self
->
pos
=
0
;
return
PyErr_NoMemory
();
}
...
...
@@ -371,8 +371,7 @@ O_cwrite(PyObject *self, char *c, int l) {
if
(
oself
->
buf_size
<=
newl
)
oself
->
buf_size
=
newl
+
1
;
UNLESS
(
oself
->
buf
=
(
char
*
)
realloc
(
oself
->
buf
,
(
oself
->
buf_size
)
*
sizeof
(
char
)))
{
(
char
*
)
realloc
(
oself
->
buf
,
oself
->
buf_size
))
{
PyErr_SetString
(
PyExc_MemoryError
,
"out of memory"
);
oself
->
buf_size
=
oself
->
pos
=
0
;
return
-
1
;
...
...
@@ -529,7 +528,7 @@ newOobject(int size) {
self
->
string_size
=
0
;
self
->
softspace
=
0
;
UNLESS
(
self
->
buf
=
malloc
(
size
*
sizeof
(
char
)
))
{
UNLESS
(
self
->
buf
=
(
char
*
)
malloc
(
size
))
{
PyErr_SetString
(
PyExc_MemoryError
,
"out of memory"
);
self
->
buf_size
=
0
;
return
NULL
;
...
...
Objects/stringobject.c
View file @
e7c05323
...
...
@@ -70,8 +70,7 @@ PyString_FromStringAndSize(const char *str, int size)
}
/* Inline PyObject_NewVar */
op
=
(
PyStringObject
*
)
PyObject_MALLOC
(
sizeof
(
PyStringObject
)
+
size
*
sizeof
(
char
));
op
=
(
PyStringObject
*
)
PyObject_MALLOC
(
sizeof
(
PyStringObject
)
+
size
);
if
(
op
==
NULL
)
return
PyErr_NoMemory
();
PyObject_INIT_VAR
(
op
,
&
PyString_Type
,
size
);
...
...
@@ -126,8 +125,7 @@ PyString_FromString(const char *str)
}
/* Inline PyObject_NewVar */
op
=
(
PyStringObject
*
)
PyObject_MALLOC
(
sizeof
(
PyStringObject
)
+
size
*
sizeof
(
char
));
op
=
(
PyStringObject
*
)
PyObject_MALLOC
(
sizeof
(
PyStringObject
)
+
size
);
if
(
op
==
NULL
)
return
PyErr_NoMemory
();
PyObject_INIT_VAR
(
op
,
&
PyString_Type
,
size
);
...
...
@@ -799,7 +797,7 @@ PyObject *
PyString_Repr
(
PyObject
*
obj
,
int
smartquotes
)
{
register
PyStringObject
*
op
=
(
PyStringObject
*
)
obj
;
size_t
newsize
=
2
+
4
*
op
->
ob_size
*
sizeof
(
char
)
;
size_t
newsize
=
2
+
4
*
op
->
ob_size
;
PyObject
*
v
;
if
(
newsize
>
INT_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
...
...
@@ -911,8 +909,7 @@ string_concat(register PyStringObject *a, register PyObject *bb)
}
size
=
a
->
ob_size
+
b
->
ob_size
;
/* Inline PyObject_NewVar */
op
=
(
PyStringObject
*
)
PyObject_MALLOC
(
sizeof
(
PyStringObject
)
+
size
*
sizeof
(
char
));
op
=
(
PyStringObject
*
)
PyObject_MALLOC
(
sizeof
(
PyStringObject
)
+
size
);
if
(
op
==
NULL
)
return
PyErr_NoMemory
();
PyObject_INIT_VAR
(
op
,
&
PyString_Type
,
size
);
...
...
@@ -948,9 +945,8 @@ string_repeat(register PyStringObject *a, register int n)
Py_INCREF
(
a
);
return
(
PyObject
*
)
a
;
}
nbytes
=
size
*
sizeof
(
char
);
if
(
nbytes
/
sizeof
(
char
)
!=
(
size_t
)
size
||
nbytes
+
sizeof
(
PyStringObject
)
<=
nbytes
)
{
nbytes
=
(
size_t
)
size
;
if
(
nbytes
+
sizeof
(
PyStringObject
)
<=
nbytes
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"repeated string is too long"
);
return
NULL
;
...
...
@@ -3495,8 +3491,7 @@ _PyString_Resize(PyObject **pv, int newsize)
_Py_DEC_REFTOTAL
;
_Py_ForgetReference
(
v
);
*
pv
=
(
PyObject
*
)
PyObject_REALLOC
((
char
*
)
v
,
sizeof
(
PyStringObject
)
+
newsize
*
sizeof
(
char
));
PyObject_REALLOC
((
char
*
)
v
,
sizeof
(
PyStringObject
)
+
newsize
);
if
(
*
pv
==
NULL
)
{
PyObject_Del
(
v
);
PyErr_NoMemory
();
...
...
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