MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_str_vsplit

Function hb_str_vsplit

libhb/common.c:6915–6957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6913}
6914
6915char** hb_str_vsplit( const char *str, char delem )
6916{
6917 const char * pos;
6918 const char * end;
6919 char ** ret;
6920 int count, i;
6921 char quote = '"';
6922
6923 if (delem == '"')
6924 {
6925 quote = '\'';
6926 }
6927 if ( str == NULL || str[0] == 0 )
6928 {
6929 ret = malloc( sizeof(char*) );
6930 if ( ret == NULL ) return ret;
6931 *ret = NULL;
6932 return ret;
6933 }
6934
6935 // Find number of elements in the string
6936 count = 1;
6937 pos = str;
6938 while ( ( pos = strchr_quote( pos, delem, quote ) ) != NULL )
6939 {
6940 count++;
6941 pos++;
6942 }
6943
6944 ret = calloc( ( count + 1 ), sizeof(char*) );
6945 if ( ret == NULL ) return ret;
6946
6947 pos = str;
6948 for ( i = 0; i < count - 1; i++ )
6949 {
6950 end = strchr_quote( pos, delem, quote );
6951 ret[i] = strndup_quote(pos, quote, end - pos);
6952 pos = end + 1;
6953 }
6954 ret[i] = strndup_quote(pos, quote, strlen(pos));
6955
6956 return ret;
6957}
6958
6959void hb_str_vfree( char **strv )
6960{

Callers 6

import_custom_11_1_0Function · 0.85
hb_parse_filter_settingsFunction · 0.85
hb_dict_extract_rationalFunction · 0.85
hb_filter_get_keysFunction · 0.85
showFilterDefaultFunction · 0.85
ParseOptionsFunction · 0.85

Calls 2

strchr_quoteFunction · 0.85
strndup_quoteFunction · 0.85

Tested by 2

showFilterDefaultFunction · 0.68
ParseOptionsFunction · 0.68