Giter Club home page Giter Club logo

Comments (3)

Philosoph228 avatar Philosoph228 commented on May 30, 2024

Hi! Thank you for your contribution. If I right understood you, the parameters of type void* and private structure definition are made for data protection. No one file beside should access this structure directly.
I see there possible improvement to define another data type based on void*.

About naming, yes, you right. When I wrote this I didn't thought much about it. I'll consider to rename it for something like you suggest, maybe refcptr_t would be a good option too.

from panitent.

Philosoph228 avatar Philosoph228 commented on May 30, 2024

Check e385fb9

from panitent.

GbaLog avatar GbaLog commented on May 30, 2024

@Philosoph228 hello.

If I right understood you, the parameters of type void* and private structure definition are made for data protection. No one file beside should access this structure directly.

yes, but i didn't propose to expose internals, i proposed exposing name with forwarding declaration.
something like this:

//.h
typedef struct refcnt_ptr refcnt_ptr_t;
//.c
struct refcnt_ptr
{
  //...
};

your variant also fits for this idiom, but it has some pitfalls.
for example, API of your smart pointer now is:
https://github.com/Aragajaga/panitent/blob/0eed94508b8756b32e73aecca6f85967d6054168/src/crefptr.h#L6-L9
i think crefptr_get return type should be void *, because it returns internal pointer, not crefptr_t.
and arguments of crefptr_new should also take void *.
this is why i prefer variant with typedef on struct. with it you would have gotten compilation errors.

also i noticed that there's no function crefptr_ref to increase ref counter.

from panitent.

Related Issues (4)

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.