savonet / ocaml-taglib

OCaml bindings to taglib.
http://liquidsoap.info/
Other
10 stars 1 forks source link

Make taglib safe-string compatible. #6

Closed bschommer closed 5 years ago

bschommer commented 5 years ago

Change char * to const char * for extracted String values and changed the return value of the caml_taglib_id3v2_render function to bytes instead of strings. Unfortunately this requires that the OCaml version is larger than 4.06.

I think this could be avoided if the result of ByteVector r = tag->render() is guaranteed to be a valid C string.

bschommer commented 5 years ago

Thanks for that PR! I believe that could make it compatible with all versions of OCaml by using Bytes.t instead of bytes. On the C side, I believe that String_val is the same as Bytes_val. Would you care do do those changes?

If safe-string is enabled at configure time then it is not equivalent and the most recent OCaml version is used it is not equivalent, then String_val returns const char* , however I think this can be probably solved by testing if CAML_SAFE_STRING is defined.

bschommer commented 5 years ago

I changed the use to Bytes_val if the CAML_SAFE_STRING macro is defined, which allows it to compile with earlier versions and works also with the current version. Still, since bytes are used the version needs to be lifted to 4.02.0