Hacker News new | ask | show | jobs
by kazinator 2604 days ago
How does this know the difference between:

  const char *cls::func(void)
  {
     return "abc"; // static: caller must not free
  }
and

  const char *cls::func(void)
  {
     return strdup("abc"); // caller must free
  }
Edit: I see: designed for large scale programs in high performance computing that use modern C++.

Modern C++ meaning, no pointers anywhere.

1 comments

It looks like this gives you a `ctypes` pointer: https://cppyy.readthedocs.io/en/latest/basic_types.html#poin...

So you handle it like any other ctypes pointer, ie. `libc = ctypes.CDLL(find_library("c")); libc.free(ptr)`

Which is not fun in Python. So yeah, better avoid raw pointers.