Giter VIP home page Giter VIP logo

Comments (7)

dodikk avatar dodikk commented on August 17, 2024
- (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.

AlexDenisov avatar AlexDenisov commented on August 17, 2024

Premature optimization?
What should I do in case when [NSArray new] returns nil?

from bloodmagic.

AlexDenisov avatar AlexDenisov commented on August 17, 2024

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.

dodikk avatar dodikk commented on August 17, 2024

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.

dodikk avatar dodikk commented on August 17, 2024

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.

AlexDenisov avatar AlexDenisov commented on August 17, 2024

Thank you, I've got your point and will check and fix such issues.

from bloodmagic.

anton-matosov avatar anton-matosov commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.