Add a simple strndup() implementation for win32.
(cherry picked from commit 38d5e58e22)
			
			
This commit is contained in:
		 Stefan Sommerfeld
					Stefan Sommerfeld
				
			
				
					committed by
					
						 Marcelo Roberto Jimenez
						Marcelo Roberto Jimenez
					
				
			
			
				
	
			
			
			 Marcelo Roberto Jimenez
						Marcelo Roberto Jimenez
					
				
			
						parent
						
							7d3fc74ff7
						
					
				
				
					commit
					a0b0ca1434
				
			| @@ -37,7 +37,15 @@ | |||||||
|  |  | ||||||
| /* strndup() is a GNU extension. Other systems must fix it with elif's. */ | /* strndup() is a GNU extension. Other systems must fix it with elif's. */ | ||||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||||
| extern char *strndup(__const char *__string, size_t __n); | 	extern char *strndup(__const char *__string, size_t __n); | ||||||
|  | #elif defined(WIN32) | ||||||
|  | 	static char *strndup(const char *__string, size_t __n) | ||||||
|  | 	{ | ||||||
|  | 		size_t strsize = strnlen(__string,__n); | ||||||
|  | 		char *newstr = (char *) malloc(strsize + 1); | ||||||
|  | 		strncpy(newstr,__string,__n); | ||||||
|  | 		return(newstr); | ||||||
|  | 	} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user