Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
19d92fc4
Commit
19d92fc4
authored
Nov 30, 2016
by
James Willis
Browse files
Free allocated memory if the cache needs to be re-allocated.
parent
55e67f34
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cache.h
View file @
19d92fc4
...
...
@@ -74,6 +74,18 @@ __attribute__((always_inline)) INLINE void cache_init(struct cache *c, size_t co
unsigned
int
sizeBytes
=
(
count
+
(
2
*
VEC_SIZE
))
*
sizeof
(
float
);
int
error
=
0
;
/* Free memory if cache has already been allocated. */
if
(
c
->
count
>
0
)
{
free
(
c
->
x
);
free
(
c
->
y
);
free
(
c
->
z
);
free
(
c
->
m
);
free
(
c
->
vx
);
free
(
c
->
vy
);
free
(
c
->
vz
);
free
(
c
->
h
);
}
error
+=
posix_memalign
((
void
**
)
&
c
->
x
,
alignment
,
sizeBytes
);
error
+=
posix_memalign
((
void
**
)
&
c
->
y
,
alignment
,
sizeBytes
);
error
+=
posix_memalign
((
void
**
)
&
c
->
z
,
alignment
,
sizeBytes
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment