summaryrefslogtreecommitdiff
path: root/apps/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugin.c')
-rw-r--r--apps/plugin.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 28d443321f..baf9b60eb8 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -93,9 +93,9 @@ static char current_plugin[MAX_PATH];
93 93
94char *plugin_get_current_filename(void); 94char *plugin_get_current_filename(void);
95 95
96#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
97/* Some wrappers used to monitor open and close and detect leaks*/ 96/* Some wrappers used to monitor open and close and detect leaks*/
98static int open_wrapper(const char* pathname, int flags); 97static int open_wrapper(const char* pathname, int flags, ...);
98#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
99static int close_wrapper(int fd); 99static int close_wrapper(int fd);
100static int creat_wrapper(const char *pathname, mode_t mode); 100static int creat_wrapper(const char *pathname, mode_t mode);
101#endif 101#endif
@@ -299,13 +299,12 @@ static const struct plugin_api rockbox_api = {
299 299
300 /* file */ 300 /* file */
301 open_utf8, 301 open_utf8,
302#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
303 (open_func)open_wrapper, 302 (open_func)open_wrapper,
303#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
304 close_wrapper, 304 close_wrapper,
305#else 305#else
306 (open_func)PREFIX(open),
307 PREFIX(close), 306 PREFIX(close),
308 #endif 307#endif
309 (read_func)PREFIX(read), 308 (read_func)PREFIX(read),
310 PREFIX(lseek), 309 PREFIX(lseek),
311#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 310#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
@@ -979,17 +978,34 @@ char *plugin_get_current_filename(void)
979 return current_plugin; 978 return current_plugin;
980} 979}
981 980
982#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 981static int open_wrapper(const char* pathname, int flags, ...)
983static int open_wrapper(const char* pathname, int flags)
984{ 982{
985 int fd = PREFIX(open)(pathname,flags); 983/* we don't have an 'open' function. it's a define. and we need
984 * the real file_open, hence PREFIX() doesn't work here */
985 int fd;
986#ifdef SIMULATOR
987 if (flags & O_CREAT)
988 {
989 va_list ap;
990 va_start(ap, flags);
991 int fd;
992 fd = sim_open(pathname, flags, va_arg(ap, mode_t));
993 va_end(ap);
994 }
995 else
996 fd = sim_open(pathname, flags);
997#else
998 fd = file_open(pathname,flags);
999#endif
986 1000
1001#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
987 if(fd >= 0) 1002 if(fd >= 0)
988 open_files |= 1<<fd; 1003 open_files |= 1<<fd;
989 1004#endif
990 return fd; 1005 return fd;
991} 1006}
992 1007
1008#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
993static int close_wrapper(int fd) 1009static int close_wrapper(int fd)
994{ 1010{
995 if((~open_files) & (1<<fd)) 1011 if((~open_files) & (1<<fd))