MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / allocate

Method allocate

eval/CIPO_evaluation/common/gason.cpp:41–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void *JsonAllocator::allocate(size_t size) {
42 size = (size + 7) & ~7;
43
44 if (head && head->used + size <= JSON_ZONE_SIZE) {
45 char *p = (char *)head + head->used;
46 head->used += size;
47 return p;
48 }
49
50 size_t allocSize = sizeof(Zone) + size;
51 Zone *zone = (Zone *)malloc(allocSize <= JSON_ZONE_SIZE ? JSON_ZONE_SIZE : allocSize);
52 if (zone == nullptr)
53 return nullptr;
54 zone->used = allocSize;
55 if (allocSize <= JSON_ZONE_SIZE || head == nullptr) {
56 zone->next = head;
57 head = zone;
58 } else {
59 zone->next = head->next;
60 head->next = zone;
61 }
62 return (char *)zone + sizeof(Zone);
63}
64
65void JsonAllocator::deallocate() {
66 while (head) {

Callers 1

jsonParseFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected