From 4023e389527f9102603c60dbecd1888d55e6b950 Mon Sep 17 00:00:00 2001 From: norly Date: Sun, 14 Jul 2019 14:21:58 +0200 Subject: Move to __uint32_t from glibc's bits/types.c This saves 50% of HDD space for the links on 64 bit platforms --- links-plain-to-binary.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'links-plain-to-binary.c') diff --git a/links-plain-to-binary.c b/links-plain-to-binary.c index 13ded29..005a496 100644 --- a/links-plain-to-binary.c +++ b/links-plain-to-binary.c @@ -3,6 +3,10 @@ #include #include #include +#include + + +typedef __uint32_t art_id; static int @@ -26,15 +30,15 @@ int main() FILE *out_file; char **title = NULL; - size_t titles = 0; - size_t titles_alloc = 0; + art_id titles = 0; + art_id titles_alloc = 0; - size_t **link; - size_t *links; + art_id **link; + art_id *links; - size_t link_titles_done = 0; + art_id link_titles_done = 0; - size_t i; + art_id i; /* @@ -73,8 +77,8 @@ int main() - link = malloc(titles * sizeof(size_t*)); - links = malloc(titles * sizeof(size_t)); + link = malloc(titles * sizeof(art_id*)); + links = malloc(titles * sizeof(art_id)); in_file = fopen("enwiki-links-plain.txt", "r"); while (!feof(in_file)) { @@ -131,7 +135,7 @@ int main() } links[i]++; - link[i] = realloc(link[i], links[i] * sizeof(size_t)); + link[i] = realloc(link[i], links[i] * sizeof(art_id)); link[i][links[i] - 1] = cur_link - title; @@ -160,7 +164,7 @@ int main() out_file = fopen("links-outgoing.bin", "wb"); fwrite(&titles, sizeof(titles), 1, out_file); for (i = 0; i < titles; i++) { - size_t j; + art_id j; fwrite(&links[i], sizeof(links[i]), 1, out_file); -- cgit v1.2.3