cocoa-rs | C bindings for the Rust programming language | iOS library
kandi X-RAY | cocoa-rs Summary
kandi X-RAY | cocoa-rs Summary
DEPRECATED - Cocoa/Objective-C bindings for the Rust programming language
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cocoa-rs
cocoa-rs Key Features
cocoa-rs Examples and Code Snippets
Community Discussions
Trending Discussions on cocoa-rs
QUESTION
I'm struggling with one issue related to the cocoa foundation memory management. Basically I have a project, written in Rust and I'm using cocoa-rs
and objc-rs
to interact with Objective-C. I'm familiar with memory management in CoreFoundation and CocoaFoundation (I've already read the corresponding articles in documentation). I did not have any memory issues when I worked with CoreFoundation functions, but I'm having a lot of problems when I use CocoaFoundation related stuff, it seems that getting any objects from CocoaFoundation leaks memory.
Here is the simplified version of one of the functions which leads to a memory memory:
...ANSWER
Answered 2017-Apr-03 at 14:30Since Objective-C ARC is not implemented in objc-rs
/cocoa-rs
, you need to follow the memory management rule, in particular for this question: You must not relinquish ownership of an object you do not own. That is you should not call autorelease()
, release()
or dealloc()
on any of the returned objects.
What you should do is to create an NSAutoreleasePool inside the function, and don't touch anything else. The pool will free all those objects when it is released.
QUESTION
It has been my understanding that C variadic arguments are handled entirely on the callee's side, i.e. that if you called a function f
with
ANSWER
Answered 2017-Feb-01 at 19:21This is a non-ABI-specific answer.
Yes, formally the caller can (and, in general case, will) treat functions with variadic arguments in a special way. This is actually the reason why from the beginning of standardized times C language required all variadic functions to be declared with prototype before the point of the call. Note that even though it was possible to safely call undeclared functions in C89/90, the permission to do so did not extend to variadic functions: those always had to be declared in advance. Otherwise, the behavior was undefined.
In a slightly different form the rule still stands in modern C. Even though post-C99 C no longer allows calling undeclared functions, it still does not require prototype declarations. Yet, variadic functions have to be declared with prototype before the point of the call. The rationale is the same: the caller has to know that it is calling a variadic function and, possibly, handle the call differently.
And historically, there were implementations that used completely differrent calling conventions when calling variadic functions.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cocoa-rs
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page