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
a9061fbb
Commit
a9061fbb
authored
11 years ago
by
Guillaume Petiot
Browse files
Options
Downloads
Patches
Plain Diff
[e-acsl] +macro E_ACSL_WARNING
parent
c4b845a0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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/memory_model/e_acsl_mmodel.c
+60
-11
60 additions, 11 deletions
src/plugins/e-acsl/share/e-acsl/memory_model/e_acsl_mmodel.c
with
60 additions
and
11 deletions
src/plugins/e-acsl/share/e-acsl/memory_model/e_acsl_mmodel.c
+
60
−
11
View file @
a9061fbb
...
...
@@ -28,6 +28,26 @@
#include
"e_acsl_mmodel_api.h"
#include
"e_acsl_mmodel.h"
#define WARNING 0
#define ERROR 1
#define IGNORE 2
#ifdef E_ACSL_WARNING
int
__warning_level
=
E_ACSL_WARNING
;
#else
int
__warning_level
=
WARNING
;
#endif
void
__warning
(
const
char
*
fct_name
)
{
fprintf
(
stderr
,
"warning: E_ACSL function '%s' called with null pointer
\n
"
,
fct_name
);
}
size_t
__memory_size
=
0
;
/*unsigned cpt_store_block = 0;*/
...
...
@@ -178,10 +198,21 @@ void* __calloc(size_t nbr_block, size_t size_block) {
void
__initialize
(
void
*
ptr
,
size_t
size
)
{
struct
_block
*
tmp
;
unsigned
i
;
assert
(
ptr
!=
NULL
);
if
(
ptr
==
NULL
)
{
if
(
__warning_level
==
ERROR
)
assert
(
0
);
else
if
(
__warning_level
==
IGNORE
)
return
;
else
{
__warning
(
"initialize"
);
return
;
}
}
assert
(
size
>
0
);
tmp
=
__get_cont
(
ptr
);
assert
(
tmp
!=
NULL
);
if
(
tmp
==
NULL
)
{
if
(
__warning_level
==
ERROR
)
assert
(
0
);
else
if
(
__warning_level
==
IGNORE
)
return
;
else
{
__warning
(
"initialize"
);
return
;
}
}
/* already fully initialized, do nothing */
if
(
tmp
->
init_cpt
==
tmp
->
size
)
return
;
...
...
@@ -211,9 +242,20 @@ void __initialize (void * ptr, size_t size) {
/* mark all bytes of ptr as initialized */
void
__full_init
(
void
*
ptr
)
{
struct
_block
*
tmp
;
assert
(
ptr
!=
NULL
);
if
(
ptr
==
NULL
)
{
if
(
__warning_level
==
ERROR
)
assert
(
0
);
else
if
(
__warning_level
==
IGNORE
)
return
;
else
{
__warning
(
"full_init"
);
return
;
}
}
tmp
=
__get_exact
(
ptr
);
assert
(
tmp
!=
NULL
);
if
(
tmp
==
NULL
)
{
if
(
__warning_level
==
ERROR
)
assert
(
0
);
else
if
(
__warning_level
==
IGNORE
)
return
;
else
{
__warning
(
"full_init"
);
return
;
}
}
if
(
tmp
->
init_ptr
!=
NULL
)
{
free
(
tmp
->
init_ptr
);
...
...
@@ -226,9 +268,21 @@ void __full_init (void * ptr) {
/* mark a block as litteral string */
void
__literal_string
(
void
*
ptr
)
{
struct
_block
*
tmp
;
assert
(
ptr
!=
NULL
);
if
(
ptr
==
NULL
)
{
if
(
__warning_level
==
ERROR
)
assert
(
0
);
else
if
(
__warning_level
==
IGNORE
)
return
;
else
{
__warning
(
"literal_string"
);
return
;
}
}
tmp
=
__get_exact
(
ptr
);
assert
(
tmp
!=
NULL
);
if
(
tmp
==
NULL
)
{
if
(
__warning_level
==
ERROR
)
assert
(
0
);
else
if
(
__warning_level
==
IGNORE
)
return
;
else
{
__warning
(
"literal_string"
);
return
;
}
}
tmp
->
is_litteral_string
=
true
;
}
...
...
@@ -269,14 +323,10 @@ size_t __block_length(void* ptr) {
/* return whether the size bytes of ptr are readable/writable */
int
__valid
(
void
*
ptr
,
size_t
size
)
{
struct
_block
*
tmp
;
/*printf("ptr = %p\n", ptr);
printf("size = %i\n", size);*/
if
(
ptr
==
NULL
)
return
false
;
assert
(
size
>
0
);
tmp
=
__get_cont
(
ptr
);
/*printf("tmp->ptr = %p\n", tmp->ptr);
printf("tmp->size = %i\n", tmp->size);*/
return
(
tmp
==
NULL
)
?
false
:
(
tmp
->
size
-
(
(
size_t
)
ptr
-
tmp
->
ptr
)
>=
size
&&
!
tmp
->
is_litteral_string
&&
!
tmp
->
is_out_of_bound
);
...
...
@@ -365,7 +415,6 @@ void __clean_block (struct _block * ptr) {
/* erase the content of the abstract structure */
void
__e_acsl_memory_clean
()
{
__clean_struct
();
/*printf("%i &\n", cpt_store_block);*/
}
/**********************/
...
...
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