X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fos_regex%2Fos_regex_strbreak.c;h=d04f3555a14f5e8a2eda20f09cbb21bb8559f5a3;hb=927951d1c1ad45ba9e7325f07d996154a91c911b;hp=e8a4228991843ac0175eae13229b12399b8cc3e4;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/os_regex/os_regex_strbreak.c b/src/os_regex/os_regex_strbreak.c index e8a4228..d04f355 100755 --- a/src/os_regex/os_regex_strbreak.c +++ b/src/os_regex/os_regex_strbreak.c @@ -5,7 +5,7 @@ * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ @@ -13,6 +13,8 @@ #include #include #include + +#include "os_regex.h" #include "os_regex_internal.h" @@ -20,17 +22,17 @@ * Split a string into multiples pieces, divided by a char "match". * Returns a NULL terminated array on success or NULL on error. */ -char **OS_StrBreak(char match, char *str, int size) +char **OS_StrBreak(char match, const char *str, size_t size) { - int count = 0; - int i = 0; - - char *tmp_str = str; + size_t count = 0; + size_t i = 0; + + const char *tmp_str = str; char **ret; - /* We can't do anything if str is null or size <= 0 */ - if((str == NULL)||(size <= 0)) + /* We can't do anything if str is null */ + if(str == NULL) return(NULL); ret = (char **)calloc(size+1, sizeof(char *)); @@ -40,7 +42,7 @@ char **OS_StrBreak(char match, char *str, int size) /* Memory error. Should provice a better way to detect it */ return(NULL); } - + /* Allocating memory to null */ while(i <= size) { @@ -62,13 +64,13 @@ char **OS_StrBreak(char match, char *str, int size) goto error; } - /* Copying the string */ + /* Copying the string */ ret[count][i-1] = '\0'; strncpy(ret[count],tmp_str,i-1); tmp_str = ++str; count++; - i=0; + i=0; continue; }