Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kevin-dong-nai-jia
Created February 12, 2018 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevin-dong-nai-jia/834e3d16c3c7f0f8496ef23945dbf7ca to your computer and use it in GitHub Desktop.
Save kevin-dong-nai-jia/834e3d16c3c7f0f8496ef23945dbf7ca to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <stdio.h>
#include "src/list/extd-ccdll.h"
int main(int argc, char **argv)
{
int argi;
if ((argc != 3) ||
((argi = atoi(argv[2])) < 0))
exit(EXIT_FAILURE);
FILE *fptr;
char *name = argv[1];
if (!(fptr = fopen(name, "rt")))
fprintf(stderr, "argv[1]: no such file\n");
else
{
char *line;
ssize_t byte;
size_t zero = 0;
ccdll(char*) list;
ccdll_init(list);
while ((line = NULL,
byte = getline(&line, &zero, fptr)) != -1)
ccdll_push_back(list, line);
free (line);
fclose(fptr);
#define SCMP_CCDLL_PREFETCH(a, b) \
(strncmp(SREF_NEXT(a), SREF_NEXT(b), argi) <= 0)
ccdll_sort_prefetch_extd(list, SCMP_CCDLL_PREFETCH);
CCDLL_INCR_EXTD(line, list, free(*line))
printf("%s", *line);
ccdll_free(list);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment