{"id":22976043,"url":"https://github.com/marcvincenti/smartpointer","last_synced_at":"2025-04-02T08:18:13.054Z","repository":{"id":70077100,"uuid":"58680258","full_name":"marcvincenti/SmartPointer","owner":"marcvincenti","description":"Smart pointers prevent most situations of memory leaks by making the memory deallocation automatic.","archived":false,"fork":false,"pushed_at":"2016-09-19T12:23:08.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T23:24:46.342Z","etag":null,"topics":["heap","pointer","smart-pointer","stack"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcvincenti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-12T22:04:06.000Z","updated_at":"2020-11-03T00:00:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc34da8e-7ae4-4634-844c-77f05b672f62","html_url":"https://github.com/marcvincenti/SmartPointer","commit_stats":null,"previous_names":["marcvincenti/smartpointer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcvincenti%2FSmartPointer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcvincenti%2FSmartPointer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcvincenti%2FSmartPointer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcvincenti%2FSmartPointer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcvincenti","download_url":"https://codeload.github.com/marcvincenti/SmartPointer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246777816,"owners_count":20832033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["heap","pointer","smart-pointer","stack"],"created_at":"2024-12-15T00:47:52.045Z","updated_at":"2025-04-02T08:18:13.048Z","avatar_url":"https://github.com/marcvincenti.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SmartPointer\n\nSmart Pointer implementation without any pool or any previous memory allocated.\n\n## How it works ?\n\nIn this case, we choose to work with contexts. We actually have just one context struct (this is why it's not thread safe today).\n\n```cpp\nextern bool sp_contexte_new;\nextern bool sp_contexte_array;\nextern void* sp_contexte_addr;\nextern std::size_t sp_contexte_size;\n```\n\n+ The **new** indicate the object is in the heap (*i.e.* we called the instruction).\n+ The **array** indicate if it's an array or not.\n+ And **addr**, **size** are the address and size of the new object.\n\nNow, we now for each SmartPointer if the pointed object is in the stack or in the heap.\nEach SmartPointer also contains the number of references from the stack **and** from the heap to the pointed object, \nthe address of the pointed object, if the SmartPointer itself is in an array and is in the heap (because of the contexts uses).\n\n```cpp\ntemplate \u003ctypename T\u003e\nstruct compteur\n{\n    T * ptr;\n    int ref_cnt_tas;\n    int ref_cnt_pile;\n    bool heap = true; //l'objet pointé est-il dans le tas?\n};\n```\n\nAnd later in class SmartPointer :\n\n```cpp\nprivate:\n\n    //Attributs\n    bool is_array;//le smartPointeur contient-il un tableau ?\n    bool tas;//le smartPointeur est-il dans le tas ?\n    compteur\u003cT\u003e * refer;//la structure reste à la fin de l'objet\n```\n\nAnd finally, we have :\n\n```cpp\ntypedef std::pair\u003cvoid*, std::pair\u003csize_t, std::list\u003cvoid*\u003e\u003e\u003e paireZone;\ntypedef std::map\u003cvoid*, std::pair\u003csize_t, std::list\u003cvoid*\u003e\u003e\u003e mapZone;\n```\n\nWhere **mapZone** is a map with the address of the pointed object as key and a pair of the size of the object \nand a list of pointer which are pointing this object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcvincenti%2Fsmartpointer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcvincenti%2Fsmartpointer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcvincenti%2Fsmartpointer/lists"}