summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/core_keymap.c7
-rw-r--r--apps/misc.c6
-rw-r--r--firmware/include/core_alloc.h12
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)
int handle = core_alloc(bufsize);
if (handle > 0)
{
- core_pin(handle);
- if (read(fd, core_get_data(handle), bufsize) == (ssize_t)bufsize)
+ void *data = core_get_data_pinned(handle);
+
+ if (read(fd, data, bufsize) == (ssize_t)bufsize)
count = action_set_keymap_handle(handle, count);
- core_unpin(handle);
+ core_put_data_pinned(data);
}
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,
handle = core_alloc_ex(buf_size, ops);
if (handle > 0)
{
- core_pin(handle);
- bm->data = core_get_data(handle);
+ bm->data = core_get_data_pinned(handle);
lseek(fd, 0, SEEK_SET); /* reset to beginning of file */
size_read = read_bmp_fd(fd, bm, buf_size, bmformat, NULL);
@@ -1645,9 +1644,10 @@ int core_load_bmp(const char * filename, struct bitmap *bm, const int bmformat,
core_shrink(handle, bm->data, size_read);
*buf_reqd = size_read;
}
+
+ core_put_data_pinned(bm->data);
bm->data = NULL; /* do this to force a crash later if the
caller doesnt call core_get_data() */
- core_unpin(handle);
}
else
*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)
return buflib_get_data(&core_ctx, handle);
}
+static inline void* core_get_data_pinned(int handle)
+{
+ extern struct buflib_context core_ctx;
+ return buflib_get_data_pinned(&core_ctx, handle);
+}
+
+static inline void core_put_data_pinned(void *data)
+{
+ extern struct buflib_context core_ctx;
+ buflib_put_data_pinned(&core_ctx, data);
+}
+
/* core context chunk_alloc */
static inline bool core_chunk_alloc_init(struct chunk_alloc_header *hdr,
size_t chunk_size, size_t max_chunks)