Loading libc using CDLL(None) rather than load_dll(c) on Mac
@@ -135,7 +135,11 @@ elif sys.platform == 'darwin':
]
_lgeos = load_dll('geos_c', fallbacks=alt_paths)
- free = load_dll('c').free
+ # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
+ # manpage says, "If filename is NULL, then the returned handle is for the
+ # main program". This way we can let the linker do the work to figure out
+ # which libc Python is actually using.
+ free = CDLL(None).free
free.argtypes = [c_void_p]
free.restype = None
