projects
/
platform
/
core
/
security
/
yaca.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0290a55
)
Simplify memory allocation in read_file
91/72991/2
author
Krzysztof Jackiewicz
<k.jackiewicz@samsung.com>
Fri, 3 Jun 2016 11:14:56 +0000
(13:14 +0200)
committer
Lukasz Pawelczyk
<l.pawelczyk@samsung.com>
Mon, 6 Jun 2016 12:43:02 +0000
(14:43 +0200)
Change-Id: Ia3cc7dd2d04fb4279ec3cc60c5858f84ace20daa
examples/misc.c
patch
|
blob
|
history
diff --git
a/examples/misc.c
b/examples/misc.c
index
5a121a8
..
693044d
100644
(file)
--- a/
examples/misc.c
+++ b/
examples/misc.c
@@
-92,16
+92,9
@@
int read_file(const char *path, char **data, size_t *data_len)
size_t read = fread(tmp, 1, BUF_SIZE, f);
if (read > 0) {
- if (buf == NULL) {
- if (yaca_malloc(read, (void**)&buf) != YACA_ERROR_NONE) {
- ret = -1;
- break;
- }
- } else {
- if (yaca_realloc(buf_len + read, (void**)&buf) != YACA_ERROR_NONE) {
- ret = -1;
- break;
- }
+ if (yaca_realloc(buf_len + read, (void**)&buf) != YACA_ERROR_NONE) {
+ ret = -1;
+ break;
}
memcpy(buf + buf_len, tmp, read);