Skip to content

Proper use of swift_allocObject()? #36

Answered by Azoy
NSExceptional asked this question in Q&A
Discussion options

You must be logged in to vote

So the correct way to call swift_allocObject is:

let object = swift_allocObject(
  for: someMetadata,
  size: someMetadata.instanceSize,
  alignment: someMetadata.instanceAlignmentMask
)

Where it will return a pointer to a heap object and the fields can be placed in the respective field offset from that pointer.

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@NSExceptional
Comment options

@Azoy
Comment options

@NSExceptional
Comment options

@Azoy
Comment options

@NSExceptional
Comment options

Answer selected by NSExceptional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants