Created
October 9, 2011 23:11
-
-
Save alyx/1274343 to your computer and use it in GitHub Desktop.
tokenizer with memory asplosion
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
/* Sigyn - A reasonably sane IRC bot. | |
* Copyright (c) Alexandria Wolcott <alyx@malkier.net> | |
* Released under the BSD license. | |
*/ | |
#include "sigyn.h" | |
int tokenize(char *message, char **parv) | |
{ | |
int i; | |
char *token, *save; | |
i = 0; | |
save = strdup(message); | |
while ((i <= MAXPARC) && (token = strtok_r(NULL, " ", &save)) && | |
(token != NULL)) | |
{ | |
printf("%d\n", i); | |
parv[i] = token; | |
i++; | |
if ((strlen(save)) < 1) | |
break; | |
} | |
if ((i > MAXPARC) && (save != NULL)) | |
parv[i] = save; | |
if (parv[i] == NULL) | |
i--; | |
free(save); | |
return i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment