{"id":22741323,"url":"https://github.com/chris-huxtable/cbhmemorykit","last_synced_at":"2025-03-30T04:13:31.477Z","repository":{"id":56904205,"uuid":"195889862","full_name":"chris-huxtable/CBHMemoryKit","owner":"chris-huxtable","description":"A safer and easy-to-use interface for managing and manipulating memory.","archived":false,"fork":false,"pushed_at":"2019-07-22T15:09:51.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-30T04:13:27.597Z","etag":null,"topics":["memory","objective-c","objective-c-library"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chris-huxtable.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}},"created_at":"2019-07-08T21:41:49.000Z","updated_at":"2019-07-22T15:09:53.000Z","dependencies_parsed_at":"2022-08-20T19:20:26.971Z","dependency_job_id":null,"html_url":"https://github.com/chris-huxtable/CBHMemoryKit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-huxtable%2FCBHMemoryKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-huxtable%2FCBHMemoryKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-huxtable%2FCBHMemoryKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-huxtable%2FCBHMemoryKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chris-huxtable","download_url":"https://codeload.github.com/chris-huxtable/CBHMemoryKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246273553,"owners_count":20750906,"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":["memory","objective-c","objective-c-library"],"created_at":"2024-12-11T00:09:42.825Z","updated_at":"2025-03-30T04:13:31.449Z","avatar_url":"https://github.com/chris-huxtable.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CBHMemoryKit\n\n[![release](https://img.shields.io/github/release/chris-huxtable/CBHMemoryKit.svg)](https://github.com/chris-huxtable/CBHMemoryKit/releases)\n[![pod](https://img.shields.io/cocoapods/v/CBHMemoryKit.svg)](https://cocoapods.org/pods/CBHMemoryKit)\n[![licence](https://img.shields.io/badge/licence-ISC-lightgrey.svg?cacheSeconds=2592000)](https://github.com/chris-huxtable/CBHMemoryKit/blob/master/LICENSE)\n[![coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg?cacheSeconds=2592000)](https://github.com/chris-huxtable/CBHMemoryKit)\n\nA safer and easy-to-use interface for managing and manipulating memory.\n\n\n## Use\n\n`CBHMemoryKit` provides safer c functions for managing and manipulating memory.\n\n#### Examples:\n\nAllocating a slice of 10 `NSUIntegers`:\n```c\nNSUInteger *slice = CBHMemory_alloc(10, sizeof(NSUInteger));\n```\n\nAllocating a slice of 10 `NSUIntegers` where each value is set to 0:\n```c\nNSUInteger *slice = CBHMemory_calloc(10, sizeof(NSUInteger));\n```\n\nReallocating a slice of 10 `NSUIntegers`  to 20:\n```c\nNSUInteger *slice = CBHMemory_alloc(10, sizeof(NSUInteger));\nslice = CBHMemory_realloc(slice, 20, sizeof(NSUInteger));\n```\n\nReallocating a slice of 10 `NSUIntegers` to 20 where each new value is set to 0:\n```c\nNSUInteger *slice = CBHMemory_calloc(10, sizeof(NSUInteger));\nslice = CBHMemory_recalloc(slice, 20, sizeof(NSUInteger));\n```\n\nSwapping bytes:\n```c\nNSUInteger *slice = {4, 5, 6, 7, 0, 1, 2, 3};\nCBHMemory_swapBytes(slice[0], slice[4], 4, sizeof(NSUInteger));\n// slice = {0, 1, 2, 3, 4, 5, 6, 7}\n```\n\nFreeing heap allocated memory:\n```c\nNSUInteger *slice = CBHMemory_calloc(10, sizeof(NSUInteger));\n\n// Do some work...\n\nCBHMemory_free(slice);\n// slice = NULL\n```\n\n## Why?\n\n### Overflows:\n\nThese functions fail if an overflow occurs.\n\n### Use-After-Free:\n\nUse-after-free errors are common. `CBHMemory_free()` helps avoid them by setting the pointer to NULL for you.\n\n\n## Licence\nCBHMemoryKit is available under the [ISC license](https://github.com/chris-huxtable/CBHMemoryKit/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-huxtable%2Fcbhmemorykit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchris-huxtable%2Fcbhmemorykit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-huxtable%2Fcbhmemorykit/lists"}