Skip to content
Snippets Groups Projects
Commit 5294dde9 authored by Kostyantyn Vorobyov's avatar Kostyantyn Vorobyov
Browse files

Removed several duplicate assertions in memory model

parent 3ea34db5
No related branches found
No related tags found
No related merge requests found
...@@ -112,9 +112,7 @@ void* __store_block(void* ptr, size_t size) { ...@@ -112,9 +112,7 @@ void* __store_block(void* ptr, size_t size) {
/* remove the block starting at ptr */ /* remove the block starting at ptr */
void __delete_block(void* ptr) { void __delete_block(void* ptr) {
struct _block * tmp; struct _block * tmp = __get_exact(ptr);
assert(ptr != NULL);
tmp = __get_exact(ptr);
assert(tmp != NULL); assert(tmp != NULL);
__clean_init(tmp); __clean_init(tmp);
__remove_element(tmp); __remove_element(tmp);
...@@ -293,11 +291,9 @@ void __literal_string (void * ptr) { ...@@ -293,11 +291,9 @@ void __literal_string (void * ptr) {
/* return whether the size bytes of ptr are initialized */ /* return whether the size bytes of ptr are initialized */
int __initialized (void * ptr, size_t size) { int __initialized (void * ptr, size_t size) {
struct _block * tmp;
unsigned i; unsigned i;
assert(ptr != NULL);
assert(size > 0); assert(size > 0);
tmp = __get_cont(ptr); struct _block * tmp = __get_cont(ptr);
if(tmp == NULL) if(tmp == NULL)
return false; return false;
...@@ -318,9 +314,7 @@ int __initialized (void * ptr, size_t size) { ...@@ -318,9 +314,7 @@ int __initialized (void * ptr, size_t size) {
/* return the length (in bytes) of the block containing ptr */ /* return the length (in bytes) of the block containing ptr */
size_t __block_length(void* ptr) { size_t __block_length(void* ptr) {
struct _block * tmp; struct _block * tmp = __get_cont(ptr);
assert(ptr != NULL);
tmp = __get_cont(ptr);
assert(tmp != NULL); assert(tmp != NULL);
return tmp->size; return tmp->size;
} }
...@@ -351,26 +345,20 @@ int __valid_read(void* ptr, size_t size) { ...@@ -351,26 +345,20 @@ int __valid_read(void* ptr, size_t size) {
/* return the base address of the block containing ptr */ /* return the base address of the block containing ptr */
void* __base_addr(void* ptr) { void* __base_addr(void* ptr) {
struct _block * tmp; struct _block * tmp = __get_cont(ptr);
assert(ptr != NULL);
tmp = __get_cont(ptr);
assert(tmp != NULL); assert(tmp != NULL);
return (void*)tmp->ptr; return (void*)tmp->ptr;
} }
/* return the offset of ptr within its block */ /* return the offset of ptr within its block */
int __offset(void* ptr) { int __offset(void* ptr) {
struct _block * tmp; struct _block * tmp = __get_cont(ptr);
assert(ptr != NULL);
tmp = __get_cont(ptr);
assert(tmp != NULL); assert(tmp != NULL);
return ((size_t)ptr - tmp->ptr); return ((size_t)ptr - tmp->ptr);
} }
void __out_of_bound(void* ptr, _Bool flag) { void __out_of_bound(void* ptr, _Bool flag) {
struct _block * tmp; struct _block * tmp = __get_cont(ptr);
assert(ptr != NULL);
tmp = __get_cont(ptr);
assert(tmp != NULL); assert(tmp != NULL);
tmp->is_out_of_bound = flag; tmp->is_out_of_bound = flag;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment