|
Joy will automatically create objects of the Struct and Union types whenever a C struct or union needs to be passed to JavaScript. By default, Struct and Union objects will only maintain a pointer to the real location of the data. This can be a problem if that memory location might become invalid in the future (if you correctly declare all variables holding structs or unions you need not worry about this). So you can also create Struct and Union objects explicitly by calling the Struct() or Union() constructor with an argument of either a type encoding or another Struct or Union object (which will be copied). Such objects will have their own private memory that is guaranteed to be freed only after the last reference to them has gone away. Refer to the Data Types section for an example of where this might by useful. |