diff options
author | jstebbins <[email protected]> | 2009-07-10 15:43:31 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-07-10 15:43:31 +0000 |
commit | 0caa74dce42dd83385e5d72e7c942522742bd7cd (patch) | |
tree | 1e0ecf42e3c085eb6a8d5a91efada81f8e82b010 | |
parent | 33e4a1354847c3d07ea81c7a53f6df4b0cbf8bb2 (diff) |
CLI: fix osx compilation problem
osx doesn't have strndup, so make our own from strncpy
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2680 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | test/test.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/test.c b/test/test.c index ba66974a5..403a2f2cd 100644 --- a/test/test.c +++ b/test/test.c @@ -2415,6 +2415,17 @@ static void ShowPresets() printf("\n>\n"); } +static char * hb_strndup( char * str, int len ) +{ + char * res; + int str_len = strlen( str ); + + res = malloc( len > str_len ? str_len + 1 : len + 1 ); + strncpy( res, str, len ); + res[len] = '\0'; + return res; +} + static char** str_split( char *str, char delem ) { char * pos; @@ -2444,7 +2455,7 @@ static char** str_split( char *str, char delem ) for ( i = 0; i < count - 1; i++ ) { end = strchr( pos, delem ); - ret[i] = strndup(pos, end - pos); + ret[i] = hb_strndup(pos, end - pos); pos = end + 1; } ret[i] = strdup(pos); |