diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-06-17 11:18:27 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-06-17 11:21:03 +0200 |
commit | 1d1792c217bee2f7aed28cbee60fc170bb56ecae (patch) | |
tree | 25fada7c66c76943eaf71f6b19d250a22c4e71ae /common/mem.c | |
parent | 3d7c1eaa185f91d597ccbe732aa9eff8e5336a62 (diff) | |
download | spice-1d1792c217bee2f7aed28cbee60fc170bb56ecae.tar.gz spice-1d1792c217bee2f7aed28cbee60fc170bb56ecae.tar.xz spice-1d1792c217bee2f7aed28cbee60fc170bb56ecae.zip |
Add spice_strnlen
Diffstat (limited to 'common/mem.c')
-rw-r--r-- | common/mem.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/mem.c b/common/mem.c index ec274bb3..ffb2fa45 100644 --- a/common/mem.c +++ b/common/mem.c @@ -28,6 +28,18 @@ } #endif +size_t spice_strnlen(const char *str, size_t max_len) +{ + size_t len = 0; + + while (len < max_len && *str != 0) { + len++; + str++; + } + + return len; +} + char *spice_strdup(const char *str) { char *copy; |