mallocForeignPtr vs. C

Edward Z. Yang ezyang at MIT.EDU
Mon Jul 12 16:53:03 EDT 2010

Excerpts from Evan Laforge's message of Mon Jul 12 16:43:45 -0400 2010:
> Yeah, that's definitely the safest and simplest.  But the copying
> defeats the purpose of passing a pointer in the first place, which was
> to not have to copy the giant array just to pass it.

Well, if your C code wasn't squirreling away the pointer, you could have
avoided the copy.  Memory copies in C are suprisingly cheap; I'm really
surprised how often I see memcpy() in high performance code (though, it may be
the case that the details of the algorithm are a much more important influence
on performance.)


More information about the Glasgow-haskell-users mailing list