-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression between 3.1.0 and 3.2.0. sass_compile_data_context now *requires* heap allocated c-strings #969
Comments
I don't really understand your concerns. It is indeed a breaking change as documented in the release notes (related issue #925). This actually only means that you have to pass libsass a copy of the source, it you are not able to tell you garbage collector, that you've given the control over to someone else! To be clear, you have to call OK, saw your example code and I guess that is all you need sigh
|
How can I avoid the undefined behaviour introduced by mismatched |
Don't allocate via c++ (new), just pass memory allocated via malloc or any other function you know the semantics of. I don't know any other way, but the sources vector has this contraint, since it frees (not delete) the memory is has assigned (meaning it has to be allocated via malloc before, and not via new). The easiest fix seems to make a copy, as with a c++ string: |
Couldn't the |
Sorry but a clear no here, because we want to allow optimal performance. Why should you want to make a copy if you only loaded it for libsass. It might be minimal, but that what the interface always was designed for (this would then need to change a lot of |
I can't give control because I'm borrowing the reference myself (from a |
Still not sure what the problem is, before libsass made the copy (always), now you can decide if you can move the memory to libsass and if not, you now have to make the copy yourself! Nothing more, nothing less! So in your situation you either need to tell your GC that it is no longer in control of that memory or you simply create a copy (which again, before libsass was always doing a copy for you, so disallowing the move of memory, which is now possible)! |
I'm going to make a copy, but if the library was making the copy it could control how it was copied and avoid |
I see this change has caused some concern :) It is actually very rare for C libraries to accept pointers form callers and free them. And unfortunately copying strings is not going to help performance, first because copying takes time, second (more important) that compiler can speed up the code if it knows pointers are Looking at the commits dealing w/the problem I have some ideas:
|
This makes it really awkward for things allocated in other ways (stack, borrowed pointers, etc.).
This also seems to have regressed between 3.1.0 and master in this commit: 3187a3c
My main concern is it is going to make the python bindings a little clunky. I used to be able to do this: https://github.com/dahlia/libsass-python/blob/python/pysass.cpp#L435 , but to implement it for 3.2.0 I'll need to malloc + copy + call (not to mention I'll have mismatched
malloc()
anddelete[]
since I can't really alloc withnew[]
in C).The text was updated successfully, but these errors were encountered: