Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
25784858
Commit
25784858
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/qstr: Use size_t instead of mp_uint_t when counting allocated bytes.
parent
1d899e17
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
py/modmicropython.c
+2
-2
2 additions, 2 deletions
py/modmicropython.c
py/mpstate.h
+2
-2
2 additions, 2 deletions
py/mpstate.h
py/qstr.c
+3
-3
3 additions, 3 deletions
py/qstr.c
py/qstr.h
+4
-4
4 additions, 4 deletions
py/qstr.h
with
11 additions
and
11 deletions
py/modmicropython.c
+
2
−
2
View file @
25784858
...
...
@@ -79,9 +79,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp
STATIC
mp_obj_t
mp_micropython_qstr_info
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
(
void
)
args
;
mp_uint
_t
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
;
size
_t
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
;
qstr_pool_info
(
&
n_pool
,
&
n_qstr
,
&
n_str_data_bytes
,
&
n_total_bytes
);
mp_printf
(
&
mp_plat_print
,
"qstr pool: n_pool=
"
UINT_FMT
", n_qstr="
UINT_FMT
"
, n_str_data_bytes=
"
UINT_FMT
"
, n_total_bytes=
"
UINT_FMT
"
\n
"
,
mp_printf
(
&
mp_plat_print
,
"qstr pool: n_pool=
%u, n_qstr=%u
, n_str_data_bytes=
%u
, n_total_bytes=
%u
\n
"
,
n_pool
,
n_qstr
,
n_str_data_bytes
,
n_total_bytes
);
if
(
n_args
==
1
)
{
// arg given means dump qstr data
...
...
This diff is collapsed.
Click to expand it.
py/mpstate.h
+
2
−
2
View file @
25784858
...
...
@@ -138,8 +138,8 @@ typedef struct _mp_state_vm_t {
// pointer and sizes to store interned string data
// (qstr_last_chunk can be root pointer but is also stored in qstr pool)
byte
*
qstr_last_chunk
;
mp_uint
_t
qstr_last_alloc
;
mp_uint
_t
qstr_last_used
;
size
_t
qstr_last_alloc
;
size
_t
qstr_last_used
;
// Stack top at the start of program
// Note: this entry is used to locate the end of the root pointer section.
...
...
This diff is collapsed.
Click to expand it.
py/qstr.c
+
3
−
3
View file @
25784858
...
...
@@ -165,7 +165,7 @@ qstr qstr_from_strn(const char *str, size_t len) {
// qstr does not exist in interned pool so need to add it
// compute number of bytes needed to intern this string
mp_uint
_t
n_bytes
=
MICROPY_QSTR_BYTES_IN_HASH
+
MICROPY_QSTR_BYTES_IN_LEN
+
len
+
1
;
size
_t
n_bytes
=
MICROPY_QSTR_BYTES_IN_HASH
+
MICROPY_QSTR_BYTES_IN_LEN
+
len
+
1
;
if
(
MP_STATE_VM
(
qstr_last_chunk
)
!=
NULL
&&
MP_STATE_VM
(
qstr_last_used
)
+
n_bytes
>
MP_STATE_VM
(
qstr_last_alloc
))
{
// not enough room at end of previously interned string so try to grow
...
...
@@ -221,7 +221,7 @@ byte *qstr_build_start(size_t len, byte **q_ptr) {
qstr
qstr_build_end
(
byte
*
q_ptr
)
{
qstr
q
=
qstr_find_strn
((
const
char
*
)
Q_GET_DATA
(
q_ptr
),
Q_GET_LENGTH
(
q_ptr
));
if
(
q
==
0
)
{
mp_uint
_t
len
=
Q_GET_LENGTH
(
q_ptr
);
size
_t
len
=
Q_GET_LENGTH
(
q_ptr
);
mp_uint_t
hash
=
qstr_compute_hash
(
Q_GET_DATA
(
q_ptr
),
len
);
Q_SET_HASH
(
q_ptr
,
hash
);
q_ptr
[
MICROPY_QSTR_BYTES_IN_HASH
+
MICROPY_QSTR_BYTES_IN_LEN
+
len
]
=
'\0'
;
...
...
@@ -253,7 +253,7 @@ const byte *qstr_data(qstr q, size_t *len) {
return
Q_GET_DATA
(
qd
);
}
void
qstr_pool_info
(
mp_uint
_t
*
n_pool
,
mp_uint
_t
*
n_qstr
,
mp_uint
_t
*
n_str_data_bytes
,
mp_uint
_t
*
n_total_bytes
)
{
void
qstr_pool_info
(
size
_t
*
n_pool
,
size
_t
*
n_qstr
,
size
_t
*
n_str_data_bytes
,
size
_t
*
n_total_bytes
)
{
*
n_pool
=
0
;
*
n_qstr
=
0
;
*
n_str_data_bytes
=
0
;
...
...
This diff is collapsed.
Click to expand it.
py/qstr.h
+
4
−
4
View file @
25784858
...
...
@@ -47,9 +47,9 @@ typedef mp_uint_t qstr;
typedef
struct
_qstr_pool_t
{
struct
_qstr_pool_t
*
prev
;
mp_uint
_t
total_prev_len
;
mp_uint
_t
alloc
;
mp_uint
_t
len
;
size
_t
total_prev_len
;
size
_t
alloc
;
size
_t
len
;
const
byte
*
qstrs
[];
}
qstr_pool_t
;
...
...
@@ -71,7 +71,7 @@ const char *qstr_str(qstr q);
size_t
qstr_len
(
qstr
q
);
const
byte
*
qstr_data
(
qstr
q
,
size_t
*
len
);
void
qstr_pool_info
(
mp_uint
_t
*
n_pool
,
mp_uint
_t
*
n_qstr
,
mp_uint
_t
*
n_str_data_bytes
,
mp_uint
_t
*
n_total_bytes
);
void
qstr_pool_info
(
size
_t
*
n_pool
,
size
_t
*
n_qstr
,
size
_t
*
n_str_data_bytes
,
size
_t
*
n_total_bytes
);
void
qstr_dump_data
(
void
);
#endif // __MICROPY_INCLUDED_PY_QSTR_H__
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment