Comments (7)
- (void)collectClasses
{
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
uint classesCount;
const char *imageName = class_getImageName(object_getClass(self));
const char **classNames = objc_copyClassNamesForImage(imageName, &classesCount);
for (uint index = 0; index < classesCount; index++) {
Class nextClass = objc_getClass(classNames[index]);
// what if push_back() throws an exception?
_cachedClasses.push_back(nextClass);
// you'll never reach ::free() statement
}
free(classNames);
from bloodmagic.
Premature optimization?
What should I do in case when [NSArray new]
returns nil
?
from bloodmagic.
I understand what you mean, but, IMHO, there a lot of cases when something might be broken, should we cover all them?
Anyway, if you see a big problem with this part of code - feel free to send a PR.
from bloodmagic.
It's not about optimizations. It's rather about proper resources management (memory) and avoiding crashes.
What should I do in case when [NSArray new] returns nil?
Nothing since it is safe to send messages to a nil
object
Still, the case with invoking ::free( NULL )
is completely different since it will eventually lead to a crash.
from bloodmagic.
there a lot of cases when something might be broken, should we cover all them?
Critical crashes should be addressed in no doubt.
Still, you are the maintainer and it's up to you setting the priorities.
from bloodmagic.
Thank you, I've got your point and will check and fix such issues.
from bloodmagic.
7.20.3.2 The free function
Synopsis
#include <stdlib.h>
void free(void *ptr);
Description
The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs.
See ISO-IEC 9899.
from bloodmagic.
Related Issues (18)
- Fix public headers to use #import <> style HOT 1
- [Wish] Add "assign once" property attribute HOT 2
- [Wish] Retain/release/autorelease attributes for CoreFoundation types
- Incorrect podfile HOT 5
- Question. How you implement custom attributes? HOT 1
- Initializer HOT 9
- bm_lazy HOT 1
- Warning: "Protocol hasn't been found" on a delegate class that does not rely on BloodMagic
- NSObject protocol is forward declared in BMPreference.h, why? HOT 2
- Needs a small adaptation for iOS 8+ HOT 1
- Bloodmagic swaps all @dynamic properties' implementatoins HOT 2
- CocoaPods 'use_frameworks!' option breaks dependency injection HOT 3
- Not working for me.
- Podspec needs to be updated for version 1.1.0
- Status of the library HOT 2
- Unregistered classes/protocols should be nil HOT 12
- Protocol parsing issue in BMPropertyTypeParser.mm HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bloodmagic.