Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
2a8351bf
Commit
2a8351bf
authored
9 years ago
by
Kostyantyn Vorobyov
Browse files
Options
Downloads
Patches
Plain Diff
[ADT model] comments
parent
6c16e115
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/share/e-acsl/adt_models/e_acsl_adt_mmodel.h
+23
-1
23 additions, 1 deletion
...lugins/e-acsl/share/e-acsl/adt_models/e_acsl_adt_mmodel.h
with
23 additions
and
1 deletion
src/plugins/e-acsl/share/e-acsl/adt_models/e_acsl_adt_mmodel.h
+
23
−
1
View file @
2a8351bf
...
@@ -161,12 +161,34 @@ void* __realloc(void* ptr, size_t size) {
...
@@ -161,12 +161,34 @@ void* __realloc(void* ptr, size_t size) {
tmp
->
init_cpt
=
size
;
tmp
->
init_cpt
=
size
;
/* realloc bigger larger block */
/* realloc bigger larger block */
else
{
else
{
/* Since realloc increases the size of the block full initialization
* becomes partial initialization, that is, we need to allocate
* tmp->init_ptr and set its first `old size' bits. */
/* Size of tmp->init_ptr in the new block */
int
nb
=
needed_bytes
(
size
);
int
nb
=
needed_bytes
(
size
);
/* Number of bits that need to be set in tmp->init_ptr */
int
nb_old
=
needed_bytes
(
tmp
->
size
);
int
nb_old
=
needed_bytes
(
tmp
->
size
);
/* Allocate tmp->init_ptr that tracks partial initialization and fully
* set nb_old bytes. Note that nb_old is not a multiple of 8 (i.e., bit
* size of a byte), the last (8 - old_size%8) bits of the last byte in
* tmp->init_ptr need to be unset. E.g., if the old size is 11 and the
* new size if 14 then tmp->init_ptr is 2 bytes and last 5 bits of
* tmp->init_ptr[1] should be unset. */
tmp
->
init_ptr
=
native_malloc
(
nb
);
tmp
->
init_ptr
=
native_malloc
(
nb
);
memset
(
tmp
->
init_ptr
,
0xFF
,
nb_old
);
memset
(
tmp
->
init_ptr
,
0xFF
,
nb_old
);
if
(
tmp
->
size
%
8
!=
0
)
/* Adjust bits in the last byte */
if
(
tmp
->
size
%
8
!=
0
)
{
/* Get fully initialize byte (255), shift right by the number of bytes
* that need to be pertained and flip, so zeroes becomes one and vice
* versa. E.g., in the above example this is as follows:
* 1111 1111 - 255
* 0001 1111 - 255 << tmp->size%8
* 1110 0000 - ~(255 << tmp->size%8) */
tmp
->
init_ptr
[
tmp
->
size
/
8
]
&=
~
(
255
<<
tmp
->
size
%
8
);
tmp
->
init_ptr
[
tmp
->
size
/
8
]
&=
~
(
255
<<
tmp
->
size
%
8
);
}
}
}
}
}
/* contains initialized and uninitialized parts */
/* contains initialized and uninitialized parts */
...
...
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