CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 10 Aug 2025 13:26:42 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20250426160557
location: https://web.archive.org/web/20250426160557/https://github.com/git/git/tree/master/alloc.c
server-timing: captures_list;dur=0.517512, exclusion.robots;dur=0.019744, exclusion.robots.policy;dur=0.009540, esindex;dur=0.010135, cdx.remote;dur=119.670631, LoadShardBlock;dur=150.982633, PetaboxLoader3.datanode;dur=100.542456, PetaboxLoader3.resolve;dur=45.183022
x-app-server: wwwb-app222
x-ts: 302
x-tr: 293
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app222; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 301
server: nginx
date: Sun, 10 Aug 2025 13:26:43 GMT
content-type: text/html; charset=utf-8
content-length: 0
x-archive-orig-date: Sat, 26 Apr 2025 16:05:57 GMT
x-archive-orig-content-length: 0
x-archive-orig-vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame,Accept-Encoding, Accept, X-Requested-With
location: https://web.archive.org/web/20250426160557/https://github.com/git/git/blob/master/alloc.c
x-archive-orig-cache-control: no-cache
x-archive-orig-strict-transport-security: max-age=31536000; includeSubdomains; preload
x-archive-orig-x-frame-options: deny
x-archive-orig-x-content-type-options: nosniff
x-archive-orig-x-xss-protection: 0
x-archive-orig-referrer-policy: no-referrer-when-downgrade
x-archive-orig-content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
x-archive-orig-server: github.com
x-archive-orig-set-cookie: _gh_sess=Cm12MrlUIdII%2Finm2PS6%2FTgxybiD0u1bmm60ke3txFByIAC2nPe%2BVXMFSRXvst1%2B%2F4%2BqFEJpiuCAmU98p2hHkkS6UWFPo5QlbLZnR0OUQWgXX3iGQ0aXRgLge9bNNNH%2BCGGEEYV5pgMNWOnLiWr0eUuxoSuaQi1iU%2BqenUFZIBCO9A%2BhjwhBMCVw5fGvq8HCt%2FEJFLbVHJaauuCP%2FkOYa5eGE4nDi7Sv7VBlNYyIYwq8y4f50wYA9rB9CINXZZ%2FgXNm7tyj8xMYwtn933V3YAQ%3D%3D--cRJuLVaHqR5tfbax--7QUFHU10cvBGRx3nKmcMIQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
x-archive-orig-set-cookie: _octo=GH1.1.785456007.1745683557; Path=/; Domain=github.com; Expires=Sun, 26 Apr 2026 16:05:57 GMT; Secure; SameSite=Lax
x-archive-orig-set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 26 Apr 2026 16:05:57 GMT; HttpOnly; Secure; SameSite=Lax
x-archive-orig-x-github-request-id: E1C2:1276:347A8A1:36F7BAA:680D0465
x-archive-orig-connection: close
cache-control: max-age=1800
memento-datetime: Sat, 26 Apr 2025 16:05:57 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Sat, 26 Apr 2025 16:05:57 GMT", ; rel="memento"; datetime="Sat, 26 Apr 2025 16:05:57 GMT", ; rel="last memento"; datetime="Sat, 26 Apr 2025 16:05:57 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: SPNOUTLINKS-20250426160417-crawl919/SPNOUTLINKS-20250426160555-00055.warc.gz
server-timing: captures_list;dur=1.033233, exclusion.robots;dur=0.034621, exclusion.robots.policy;dur=0.014447, esindex;dur=0.016868, cdx.remote;dur=54.178752, LoadShardBlock;dur=436.137015, PetaboxLoader3.resolve;dur=385.770014, PetaboxLoader3.datanode;dur=214.981761, load_resource;dur=196.513379
x-app-server: wwwb-app222
x-ts: 301
x-tr: 718
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 302
server: nginx
date: Sun, 10 Aug 2025 13:26:44 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20250407124742
location: https://web.archive.org/web/20250407124742/https://github.com/git/git/blob/master/alloc.c
server-timing: captures_list;dur=1.228288, exclusion.robots;dur=0.024503, exclusion.robots.policy;dur=0.009540, esindex;dur=0.012094, cdx.remote;dur=701.312467, LoadShardBlock;dur=304.686967, PetaboxLoader3.datanode;dur=106.236538, PetaboxLoader3.resolve;dur=54.592527
x-app-server: wwwb-app222
x-ts: 302
x-tr: 1031
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 10 Aug 2025 13:26:48 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Mon, 07 Apr 2025 12:47:42 GMT
x-archive-orig-vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame,Accept-Encoding, Accept, X-Requested-With
x-archive-orig-etag: W/"ec0fed6a2e95f37e8b2d763f4eeca3b4"
x-archive-orig-cache-control: max-age=0, private, must-revalidate
x-archive-orig-strict-transport-security: max-age=31536000; includeSubdomains; preload
x-archive-orig-x-frame-options: deny
x-archive-orig-x-content-type-options: nosniff
x-archive-orig-x-xss-protection: 0
x-archive-orig-referrer-policy: no-referrer-when-downgrade
x-archive-orig-content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
x-archive-orig-server: github.com
x-archive-orig-accept-ranges: bytes
x-archive-orig-set-cookie: _gh_sess=VQynXd%2BEluXMozlypApj4Nc%2F%2FLXc6uQOh9HEalBKLZOqTDUFucf2uYjsw5IjvxkIWmBa0hws%2FmyQCc8KL71CWi5XVtoPQeK6aBoRt%2BwENuck45egy4BU1Pe9aWI1P%2FTdodtwEFC9QKxnAybDi3yJKmfg0l8En7g0r8GrtJb8klbWsEeDbrxvTJxBVlWi2p1EU3WD%2FLKdsVdp3%2Fs%2Ff9XETdWXzWCMMOD2pqRHM3zG0LzwKs056%2FuGYf%2BGAqA4zaJfhHl%2FBokXBkCtbh7xuTs8xA%3D%3D--RQ7W4ZkVUajSj8be--uC7Nf%2FrA3H%2B%2B4sE%2BwQEjWQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
x-archive-orig-set-cookie: _octo=GH1.1.619690764.1744030062; Path=/; Domain=github.com; Expires=Tue, 07 Apr 2026 12:47:42 GMT; Secure; SameSite=Lax
x-archive-orig-set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Tue, 07 Apr 2026 12:47:42 GMT; HttpOnly; Secure; SameSite=Lax
x-archive-orig-x-github-request-id: B3A4:156DAC:75DF46:7B1753:67F3C96E
x-archive-orig-connection: close
x-archive-orig-transfer-encoding: chunked
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
x-archive-orig-content-encoding: gzip
memento-datetime: Mon, 07 Apr 2025 12:47:42 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 25 Jul 2017 18:09:30 GMT", ; rel="prev memento"; datetime="Mon, 07 Apr 2025 11:06:50 GMT", ; rel="memento"; datetime="Mon, 07 Apr 2025 12:47:42 GMT", ; rel="last memento"; datetime="Mon, 07 Apr 2025 12:47:42 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: SPNOUTLINKS-20250407122624-crawl922/SPNOUTLINKS-20250407124105-00336.warc.gz
server-timing: captures_list;dur=0.516597, exclusion.robots;dur=0.021012, exclusion.robots.policy;dur=0.009373, esindex;dur=0.012103, cdx.remote;dur=1950.521614, LoadShardBlock;dur=1202.629015, PetaboxLoader3.datanode;dur=1122.485146, load_resource;dur=196.084084, PetaboxLoader3.resolve;dur=147.277050
x-app-server: wwwb-app222
x-ts: 200
x-tr: 3565
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
git/alloc.c at master · git/git · GitHub
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
Copy pathalloc.c
123 lines (105 loc) · 2.71 KB
/
alloc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* alloc.c - specialized allocator for internal objects
*
* Copyright (C) 2006 Linus Torvalds
*
* The standard malloc/free wastes too much space for objects, partly because
* it maintains all the allocation infrastructure, but even more because it ends
* up with maximal alignment because it doesn't know what the object alignment
* for the new allocation is.
*/
#include "git-compat-util.h"
#include "object.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
#include "repository.h"
#include "tag.h"
#include "alloc.h"
#define BLOCKING 1024
union any_object {
struct object object;
struct blob blob;
struct tree tree;
struct commit commit;
struct tag tag;
};
struct alloc_state {
int nr; /* number of nodes left in current allocation */
void *p; /* first free node in current allocation */
/* bookkeeping of allocations */
void **slabs;
int slab_nr, slab_alloc;
};
struct alloc_state *allocate_alloc_state(void)
{
return xcalloc(1, sizeof(struct alloc_state));
}
void clear_alloc_state(struct alloc_state *s)
{
while (s->slab_nr > 0) {
s->slab_nr--;
free(s->slabs[s->slab_nr]);
}
FREE_AND_NULL(s->slabs);
}
static inline void *alloc_node(struct alloc_state *s, size_t node_size)
{
void *ret;
if (!s->nr) {
s->nr = BLOCKING;
s->p = xmalloc(BLOCKING * node_size);
ALLOC_GROW(s->slabs, s->slab_nr + 1, s->slab_alloc);
s->slabs[s->slab_nr++] = s->p;
}
s->nr--;
ret = s->p;
s->p = (char *)s->p + node_size;
memset(ret, 0, node_size);
return ret;
}
void *alloc_blob_node(struct repository *r)
{
struct blob *b = alloc_node(r->parsed_objects->blob_state, sizeof(struct blob));
b->object.type = OBJ_BLOB;
return b;
}
void *alloc_tree_node(struct repository *r)
{
struct tree *t = alloc_node(r->parsed_objects->tree_state, sizeof(struct tree));
t->object.type = OBJ_TREE;
return t;
}
void *alloc_tag_node(struct repository *r)
{
struct tag *t = alloc_node(r->parsed_objects->tag_state, sizeof(struct tag));
t->object.type = OBJ_TAG;
return t;
}
void *alloc_object_node(struct repository *r)
{
struct object *obj = alloc_node(r->parsed_objects->object_state, sizeof(union any_object));
obj->type = OBJ_NONE;
return obj;
}
/*
* The returned count is to be used as an index into commit slabs,
* that are *NOT* maintained per repository, and that is why a single
* global counter is used.
*/
static unsigned int alloc_commit_index(void)
{
static unsigned int parsed_commits_count;
return parsed_commits_count++;
}
void init_commit_node(struct commit *c)
{
c->object.type = OBJ_COMMIT;
c->index = alloc_commit_index();
}
void *alloc_commit_node(struct repository *r)
{
struct commit *c = alloc_node(r->parsed_objects->commit_state, sizeof(struct commit));
init_commit_node(c);
return c;
}
You can’t perform that action at this time.