C, Python, ctypes exit code -1073741819 (0xC0000005) -
c code(dll)
#include <math.h> #include <wchar.h> #include <stdlib.h> struct doc { wchar_t path[512]; int r; int g; int b; }; struct docs { struct doc docs[1000000]; }; struct color { int r; int g; int b; }; float distance(int a, int b, int c, int d, int e, int f) { return sqrt((a-b)*(a-b)+(c-d)*(c-d)+(e-f)*(e-f)); } struct doc main(long len, struct color c, struct docs ds) { long near = 1000000; long l; struct doc f_d; (l = 0; l < len; l++){ struct doc d = ds.docs[l]; float dist = distance(c.r, d.r, c.g, d.g, c.b, d.b); if (dist < near){ near = dist; f_d = d; } } return f_d; };
python code
class doc(ctypes.structure): _fields_ = [("path", ctypes.c_wchar_p), ("r", ctypes.c_int), ("g", ctypes.c_int), ("b", ctypes.c_int)] class docs(ctypes.structure): _fields_ = [("docs", doc * 1000000)] class color(ctypes.structure): _fields_ = [("r", ctypes.c_int), ("g", ctypes.c_int), ("b", ctypes.c_int)] structure = ctypes.cdll('st.dll').main structure.restype = doc structure.argstypes = (ctypes.c_long, color(), docs(),)
after calling main function python drops exit code -1073741819
after exe
execution returns "process finished exit code -1073741819 (0xc0000005)"
think because of memory allocation or that.
Comments
Post a Comment