diff options
-rw-r--r-- | apps/core_keymap.c | 7 | ||||
-rw-r--r-- | apps/misc.c | 6 | ||||
-rw-r--r-- | firmware/include/core_alloc.h | 12 |
3 files changed, 19 insertions, 6 deletions
diff --git a/apps/core_keymap.c b/apps/core_keymap.c index 966f32057a..89e7913c33 100644 --- a/apps/core_keymap.c +++ b/apps/core_keymap.c | |||
@@ -80,11 +80,12 @@ int core_load_key_remap(const char *filename) | |||
80 | int handle = core_alloc(bufsize); | 80 | int handle = core_alloc(bufsize); |
81 | if (handle > 0) | 81 | if (handle > 0) |
82 | { | 82 | { |
83 | core_pin(handle); | 83 | void *data = core_get_data_pinned(handle); |
84 | if (read(fd, core_get_data(handle), bufsize) == (ssize_t)bufsize) | 84 | |
85 | if (read(fd, data, bufsize) == (ssize_t)bufsize) | ||
85 | count = action_set_keymap_handle(handle, count); | 86 | count = action_set_keymap_handle(handle, count); |
86 | 87 | ||
87 | core_unpin(handle); | 88 | core_put_data_pinned(data); |
88 | } | 89 | } |
89 | 90 | ||
90 | close(fd); | 91 | close(fd); |
diff --git a/apps/misc.c b/apps/misc.c index e6c8a219ea..e17df02bff 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1635,8 +1635,7 @@ int core_load_bmp(const char * filename, struct bitmap *bm, const int bmformat, | |||
1635 | handle = core_alloc_ex(buf_size, ops); | 1635 | handle = core_alloc_ex(buf_size, ops); |
1636 | if (handle > 0) | 1636 | if (handle > 0) |
1637 | { | 1637 | { |
1638 | core_pin(handle); | 1638 | bm->data = core_get_data_pinned(handle); |
1639 | bm->data = core_get_data(handle); | ||
1640 | lseek(fd, 0, SEEK_SET); /* reset to beginning of file */ | 1639 | lseek(fd, 0, SEEK_SET); /* reset to beginning of file */ |
1641 | size_read = read_bmp_fd(fd, bm, buf_size, bmformat, NULL); | 1640 | size_read = read_bmp_fd(fd, bm, buf_size, bmformat, NULL); |
1642 | 1641 | ||
@@ -1645,9 +1644,10 @@ int core_load_bmp(const char * filename, struct bitmap *bm, const int bmformat, | |||
1645 | core_shrink(handle, bm->data, size_read); | 1644 | core_shrink(handle, bm->data, size_read); |
1646 | *buf_reqd = size_read; | 1645 | *buf_reqd = size_read; |
1647 | } | 1646 | } |
1647 | |||
1648 | core_put_data_pinned(bm->data); | ||
1648 | bm->data = NULL; /* do this to force a crash later if the | 1649 | bm->data = NULL; /* do this to force a crash later if the |
1649 | caller doesnt call core_get_data() */ | 1650 | caller doesnt call core_get_data() */ |
1650 | core_unpin(handle); | ||
1651 | } | 1651 | } |
1652 | else | 1652 | else |
1653 | *buf_reqd = buf_size; /* couldn't allocate pass bytes needed */ | 1653 | *buf_reqd = buf_size; /* couldn't allocate pass bytes needed */ |
diff --git a/firmware/include/core_alloc.h b/firmware/include/core_alloc.h index 22cc1988da..dc9b2036ec 100644 --- a/firmware/include/core_alloc.h +++ b/firmware/include/core_alloc.h | |||
@@ -45,6 +45,18 @@ static inline void* core_get_data(int handle) | |||
45 | return buflib_get_data(&core_ctx, handle); | 45 | return buflib_get_data(&core_ctx, handle); |
46 | } | 46 | } |
47 | 47 | ||
48 | static inline void* core_get_data_pinned(int handle) | ||
49 | { | ||
50 | extern struct buflib_context core_ctx; | ||
51 | return buflib_get_data_pinned(&core_ctx, handle); | ||
52 | } | ||
53 | |||
54 | static inline void core_put_data_pinned(void *data) | ||
55 | { | ||
56 | extern struct buflib_context core_ctx; | ||
57 | buflib_put_data_pinned(&core_ctx, data); | ||
58 | } | ||
59 | |||
48 | /* core context chunk_alloc */ | 60 | /* core context chunk_alloc */ |
49 | static inline bool core_chunk_alloc_init(struct chunk_alloc_header *hdr, | 61 | static inline bool core_chunk_alloc_init(struct chunk_alloc_header *hdr, |
50 | size_t chunk_size, size_t max_chunks) | 62 | size_t chunk_size, size_t max_chunks) |