Created
April 22, 2021 06:39
-
-
Save alsamitech/6dedd968483644b0d92ebfe23538ef9a to your computer and use it in GitHub Desktop.
The Compound Tokenizer, but faster.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char** atokl(char* InC, char* delim, long unsigned int* len){ | |
long unsigned int capacity=32; | |
char** tok=(char**)malloc(capacity*sizeof(char**)); | |
//printf("%p\n", tok); | |
tok[0]=strtok(strdup(InC), delim); | |
{ | |
long unsigned int i=1; | |
while(tok[i-1]!=NULL){ | |
if(i+2>=capacity){ | |
capacity+=32; | |
tok=(char**)realloc(tok, capacity*sizeof(char**)); | |
if(!tok){ | |
// something failed | |
return 0x0; | |
} | |
} | |
tok[i]=strtok(NULL, delim); | |
//printf("%p\n", tok[i]); | |
i++; | |
} | |
*len=i; | |
/*EBRACE*/} | |
return tok; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment