/* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: perl_c.c,v 1.21 2005-01-29 12:22:49 rich Exp $
+ * $Id: perl_c.c,v 1.22 2005-02-13 16:33:27 rich Exp $
*/
#include <stdio.h>
STRLEN len;
CAMLlocal1 (strv);
str = SvPV (sv, len);
- /* XXX This won't work if the string contains NUL. */
- strv = caml_copy_string (str);
+ strv = caml_alloc_string (len);
+ memcpy (String_val (strv), str, len);
CAMLreturn (strv);
}