Skip to content
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

PixelData stores a Ptr #22

Open
dagit opened this issue Jan 14, 2012 · 0 comments
Open

PixelData stores a Ptr #22

dagit opened this issue Jan 14, 2012 · 0 comments

Comments

@dagit
Copy link
Member

dagit commented Jan 14, 2012

There are use cases where storing a Ptr a makes sense and the caller will clean up the memory when done with it. For example, if the caller has a ForeignPtr already you might see code like this:

withForeignPtr ptr $ \p -> do
  let pd = PixelData ... p
  ...

Here, the withForeignPtr will clean up p when done with it and pd should not escape (it is undefined outside of withForeignPtr).

I could also imagine a case where the PixelData is created outside of a withForeignPtr and the creator wants to associate a finalizer with the pointer stored inside. For this reason it may make sense to have a variant of PixelData that supports ForeignPtr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant