diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-04-03 11:16:39 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-16 14:50:39 +0100 |
commit | 1718cf5f8a39b922eba3ad1b3c9a9570188362b1 (patch) | |
tree | 4f6bf81cb4f382ca04856b98492289825133c5ae /apps/gui/skin_engine/skin_parser.c | |
parent | b16bae6fe624d30631bf83290e204197ab136c12 (diff) | |
download | rockbox-1718cf5f8a39b922eba3ad1b3c9a9570188362b1.tar.gz rockbox-1718cf5f8a39b922eba3ad1b3c9a9570188362b1.zip |
Convert a number of allocations to use buflib pinning
Several places in the codebase implemented an ad-hoc form of pinning;
they can be converted to use buflib pinning instead.
Change-Id: I4450be007e80f6c9cc9f56c2929fa4b9b85ebff3
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 047c4735a0..2eef2af7c0 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -1870,13 +1870,11 @@ static void skin_data_reset(struct wps_data *wps_data) | |||
1870 | } | 1870 | } |
1871 | 1871 | ||
1872 | #ifndef __PCTOOL__ | 1872 | #ifndef __PCTOOL__ |
1873 | static int currently_loading_handle = -1; | ||
1874 | static int buflib_move_callback(int handle, void* current, void* new) | 1873 | static int buflib_move_callback(int handle, void* current, void* new) |
1875 | { | 1874 | { |
1875 | (void)handle; | ||
1876 | (void)current; | 1876 | (void)current; |
1877 | (void)new; | 1877 | (void)new; |
1878 | if (handle == currently_loading_handle) | ||
1879 | return BUFLIB_CB_CANNOT_MOVE; | ||
1880 | /* Any active skins may be scrolling - which means using viewports which | 1878 | /* Any active skins may be scrolling - which means using viewports which |
1881 | * will be moved after this callback returns. This is a hammer to make that | 1879 | * will be moved after this callback returns. This is a hammer to make that |
1882 | * safe. TODO: use a screwdriver instead. | 1880 | * safe. TODO: use a screwdriver instead. |
@@ -1890,14 +1888,6 @@ static int buflib_move_callback(int handle, void* current, void* new) | |||
1890 | return BUFLIB_CB_OK; | 1888 | return BUFLIB_CB_OK; |
1891 | } | 1889 | } |
1892 | static struct buflib_callbacks buflib_ops = {buflib_move_callback, NULL, NULL}; | 1890 | static struct buflib_callbacks buflib_ops = {buflib_move_callback, NULL, NULL}; |
1893 | static void lock_handle(int handle) | ||
1894 | { | ||
1895 | currently_loading_handle = handle; | ||
1896 | } | ||
1897 | static void unlock_handle(void) | ||
1898 | { | ||
1899 | currently_loading_handle = -1; | ||
1900 | } | ||
1901 | #endif | 1891 | #endif |
1902 | 1892 | ||
1903 | static int load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* bmpdir) | 1893 | static int load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* bmpdir) |
@@ -1944,12 +1934,12 @@ static int load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* | |||
1944 | _stats->buflib_handles++; | 1934 | _stats->buflib_handles++; |
1945 | _stats->images_size += buf_size; | 1935 | _stats->images_size += buf_size; |
1946 | lseek(fd, 0, SEEK_SET); | 1936 | lseek(fd, 0, SEEK_SET); |
1947 | lock_handle(handle); | 1937 | core_pin(handle); |
1948 | bitmap->data = core_get_data(handle); | 1938 | bitmap->data = core_get_data(handle); |
1949 | int ret = read_bmp_fd(fd, bitmap, buf_size, format, NULL); | 1939 | int ret = read_bmp_fd(fd, bitmap, buf_size, format, NULL); |
1950 | bitmap->data = NULL; /* do this to force a crash later if the | 1940 | bitmap->data = NULL; /* do this to force a crash later if the |
1951 | caller doesnt call core_get_data() */ | 1941 | caller doesnt call core_get_data() */ |
1952 | unlock_handle(); | 1942 | core_unpin(handle); |
1953 | close(fd); | 1943 | close(fd); |
1954 | if (ret > 0) | 1944 | if (ret > 0) |
1955 | { | 1945 | { |