Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
blaar
blibs
blc_core
Commits
7382710e
Commit
7382710e
authored
Oct 13, 2016
by
Arnaud Blanchard
Browse files
Add a function .free to the blc_mem
parent
15eb9a46
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/blc_mem.h
View file @
7382710e
...
...
@@ -80,6 +80,8 @@ typedef struct blc_mem {
void
replace
(
char
const
*
new_data
,
size_t
size
);
/** Reset all the value to 'value'. */
void
reset
(
int
value
=
0
);
void
free
();
#endif
}
blc_mem
;
...
...
src/blc_array.cpp
View file @
7382710e
...
...
@@ -75,8 +75,8 @@ void blc_array::def_array(uint32_t type, uint32_t format, char const *dims_strin
}
void
blc_array
::
destroy
(){
FREE
(
data
);
FREE
(
dims
);
free
(
);
::
free
(
dims
);
}
void
blc_array
::
add_dim
(
int
length
,
int
step
){
...
...
@@ -98,7 +98,7 @@ void blc_array::set_dims(int dims_nb, int length, ...){
blc_dim
*
dim
;
va_list
args
;
FREE
(
dims
);
::
free
(
dims
);
this
->
dims_nb
=
dims_nb
;
dims
=
MANY_ALLOCATIONS
(
dims_nb
,
blc_dim
);
...
...
src/blc_mem.cpp
View file @
7382710e
...
...
@@ -41,7 +41,7 @@ void blc_mem::allocate(size_t new_size)
{
if
(
new_size
!=
size
||
data
==
NULL
)
// Changement de taille ou l'allocation n'a encore jamais été faite
{
free
(
data
);
::
free
(
data
);
data
=
MANY_ALLOCATIONS
(
new_size
,
char
);
size
=
new_size
;
}
...
...
@@ -50,7 +50,7 @@ void blc_mem::allocate(size_t new_size)
void
blc_mem
::
allocate_min
(
size_t
new_size
)
{
if
(
new_size
>
size
){
free
(
data
);
::
free
(
data
);
data
=
MANY_ALLOCATIONS
(
new_size
,
char
);
size
=
new_size
;
}
...
...
@@ -85,6 +85,12 @@ void blc_mem::reset(int value){
memset
(
data
,
value
,
size
);
}
void
blc_mem
::
free
(){
::
free
(
data
);
//:: not calling itself but system call
data
=
NULL
;
size
=
0
;
}
/* C wrapper */
extern
"C"
{
void
blc_mem_allocate
(
blc_mem
*
mem
,
size_t
size
)
...
...
Write
Preview
Supports
Markdown
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