Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:13.2:Update
qiv
magic-optimization.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File magic-optimization.patch of Package qiv
From: Jiri Slaby <jslaby@suse.cz> Subject: Optimize libmagic calls References: bnc#804323 magic_open, magic_load and magic_close need to be called only once. So optimize this by moving at appropriate place. This BTW fixes a bug in libmagic which causes crashes on second invocation of magic_load. That is to be fixed but it is a different story for libmagic developers. --- main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) --- a/main.c +++ b/main.c @@ -32,7 +32,7 @@ static gboolean qiv_handle_timer(gpointe static void qiv_timer_restart(gpointer); #ifdef HAVE_MAGIC -static int check_magic(const char *name); +static int check_magic(magic_t cookie, const char *name); #endif int main(int argc, char **argv) @@ -227,11 +227,17 @@ static void qiv_timer_restart(gpointer d static void filter_images(int *images, char **image_names) { int i = 0; +#ifdef HAVE_MAGIC + magic_t cookie; + + cookie = magic_open(MAGIC_NONE); + magic_load(cookie,NULL); +#endif while(i < *images) { if (check_extension(image_names[i]) #ifdef HAVE_MAGIC - || check_magic(image_names[i]) + || check_magic(cookie, image_names[i]) #endif ) { i++; @@ -246,6 +252,9 @@ static void filter_images(int *images, c --(*images); } } +#ifdef HAVE_MAGIC + magic_close(cookie); +#endif if (image_idx < 0) image_idx = 0; } @@ -264,15 +273,12 @@ static int check_extension(const char *n } #ifdef HAVE_MAGIC -static int check_magic(const char *name) +static int check_magic(magic_t cookie, const char *name) { - magic_t cookie; const char *description=NULL; int i; int ret=0; - cookie = magic_open(MAGIC_NONE); - magic_load(cookie,NULL); description = magic_file(cookie, name); if(description) { @@ -283,7 +289,6 @@ static int check_magic(const char *name) break; } } - magic_close(cookie); return ret; } #endif
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor