Skip to content

Commit 1c40835

Browse files
committed
Add b_do_dlopen_dispatch
This way the higher-level b_do_dlopen function now doesn't have to worry about OS-specific logic, and can concentrate on dealing with the different types of arguments instead. Signed-off-by: Rodrigo Tobar <[email protected]>
1 parent 7c4799a commit 1c40835

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/c/_cffi_backend.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4416,6 +4416,15 @@ static void *b_do_dlopen_win32(PyObject *filename_unicode, int flags, const char
44164416
}
44174417
#endif
44184418

4419+
static void *b_do_dlopen_dispatch(PyObject *filename_unicode, int flags, const char *printable_filename)
4420+
{
4421+
#ifdef MS_WIN32
4422+
return b_do_dlopen_win32(filename_unicode, flags, printable_filename);
4423+
#else
4424+
return b_do_dlopen_posix(filename_unicode, flags, printable_filename);
4425+
#endif
4426+
}
4427+
44194428
static void *b_do_dlopen(PyObject *args, const char **p_printable_filename,
44204429
PyObject **p_temp, int *auto_close)
44214430
{
@@ -4435,11 +4444,7 @@ static void *b_do_dlopen(PyObject *args, const char **p_printable_filename,
44354444
&dummy, &flags))
44364445
return NULL;
44374446
*p_printable_filename = "<None>";
4438-
#ifdef MS_WIN32
4439-
return b_do_dlopen_win32(NULL, flags, *p_printable_filename);
4440-
#else
4441-
return b_do_dlopen_posix(NULL, flags, *p_printable_filename);
4442-
#endif
4447+
return b_do_dlopen_dispatch(NULL, flags, *p_printable_filename);
44434448
}
44444449
else if (CData_Check(PyTuple_GET_ITEM(args, 0)))
44454450
{
@@ -4472,11 +4477,7 @@ static void *b_do_dlopen(PyObject *args, const char **p_printable_filename,
44724477
if (*p_printable_filename == NULL) {
44734478
return NULL;
44744479
}
4475-
#ifdef MS_WIN32
4476-
return b_do_dlopen_win32(filename_unicode, flags, *p_printable_filename);
4477-
#else
4478-
return b_do_dlopen_posix(filename_unicode, flags, *p_printable_filename);
4479-
#endif
4480+
return b_do_dlopen_dispatch(filename_unicode, flags, *p_printable_filename);
44804481
}
44814482
}
44824483

0 commit comments

Comments
 (0)