Move to a class structure#121
Conversation
|
@gocarlos I have no idea if the way that I have done things in this PR make any sense. Can you comment? |
|
|
||
| typedef struct _COSE_KEY { | ||
| #ifdef __cplusplus | ||
| class COSE_KEY { |
There was a problem hiding this comment.
I'd say that all internal source code is cpp, so no check needed, public headers should have either a C api or (better) both, modern cpp and ABI stable C api
There was a problem hiding this comment.
I did this rather than do the conversion on dumper from c to cpp. Otherwise I agree withyou
|
|
||
| ~COSE_KEY(); | ||
|
|
||
| int AddRef() { return m_refCount += 1; } |
There was a problem hiding this comment.
why no using shared pointers? this has issues with multi threading, shared pointers solved this already
There was a problem hiding this comment.
I was not sure how I could use shared pointers. The problem is that we are returning the pointer to C code and then having it call back. I thought that the shared-pointer code was designed for only having the pointer in the class and not moving it back and forth.
| static COSE_KEY *KeysRoot; | ||
|
|
||
| public: | ||
| COSE_KEY() |
There was a problem hiding this comment.
from the naming: I'd keep UPPERCASE_VARS to macros
gocarlos
left a comment
There was a problem hiding this comment.
Left some comments, i think that we should evtl. starting to put some classes and memory mngm inside those classes... doing this with those new operators seems to me in the long run not like improving the existing structure and not well maintanable
|
|
||
| pkey = (COSE_KEY *)COSE_CALLOC(1, sizeof(COSE_KEY), context); | ||
|
|
||
| pkey = new (std::nothrow, context) COSE_KEY(); |
There was a problem hiding this comment.
I dont think thia is the way forward...
Better create something like a factory patter which returns a shared ptr.
| KeysRoot = pkey; | ||
|
|
||
| return (HCOSE_KEY)pkey; | ||
| return reinterpret_cast<HCOSE_KEY>(pkey); |
There was a problem hiding this comment.
We should get rid of all those casts
Using classes will make it easier to figure out inheritance issues.