diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-04-25 22:25:03 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-04-25 22:33:05 +0200 |
commit | 6e681f48d058cbc7be60556aaf9643f72101be68 (patch) | |
tree | 90159627bad0fc70b71a7bac937727c70e1f45c2 /NitrokeyManager.cc | |
parent | 6e5847809c5c4c68f916fda4351c0b5e279915ed (diff) | |
download | libnitrokey-6e681f48d058cbc7be60556aaf9643f72101be68.tar.gz libnitrokey-6e681f48d058cbc7be60556aaf9643f72101be68.tar.bz2 |
Use own strndup implementation under Windows
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r-- | NitrokeyManager.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index 60c1a24..5939cbf 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -14,6 +14,18 @@ namespace nitrokey{ std::mutex mex_dev_com; +#ifdef __WIN32 +#pragma message "Using own strndup" +char * strndup(const char* str, size_t maxlen){ + size_t len = strnlen(str, maxlen); + char* dup = (char *) malloc(len + 1); + memcpy(dup, str, len); + dup[len] = 0; + return dup; +} +#endif + + /** * Copies string from pointer to fixed size C-style array. Src needs to be a valid C-string - eg. ended with '\0'. |