diff options
author | Nikias Bassen | 2018-11-29 01:31:26 +0100 |
---|---|---|
committer | Nikias Bassen | 2018-11-29 01:31:26 +0100 |
commit | 537b543d821e6808ba0508723fa6e9adabb61391 (patch) | |
tree | f214b808d018ad44bcbb7a853c3bc502c1b3c3ce /src | |
parent | 74536d7a6737e2a4afb006106f1ce30a9a5aeea5 (diff) | |
download | libplist-537b543d821e6808ba0508723fa6e9adabb61391.tar.gz libplist-537b543d821e6808ba0508723fa6e9adabb61391.tar.bz2 |
bplist: Remove redundant calls to strlen()
Diffstat (limited to 'src')
-rw-r--r-- | src/bplist.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/bplist.c b/src/bplist.c index a9724b8..1ecbd66 100644 --- a/src/bplist.c +++ b/src/bplist.c @@ -1023,9 +1023,8 @@ static void write_data(bytearray_t * bplist, uint8_t * val, uint64_t size) write_raw_data(bplist, BPLIST_DATA, val, size); } -static void write_string(bytearray_t * bplist, char *val) +static void write_string(bytearray_t * bplist, char *val, uint64_t size) { - uint64_t size = strlen(val); write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size); } @@ -1188,7 +1187,6 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) uint64_t *offsets = NULL; bplist_trailer_t trailer; //for string - long len = 0; long items_read = 0; long items_written = 0; uint16_t *unicodestr = NULL; @@ -1256,14 +1254,13 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) case PLIST_KEY: case PLIST_STRING: - len = strlen(data->strval); - if ( is_ascii_string(data->strval, len) ) + if ( is_ascii_string(data->strval, data->length) ) { - write_string(bplist_buff, data->strval); + write_string(bplist_buff, data->strval, data->length); } else { - unicodestr = plist_utf8_to_utf16(data->strval, len, &items_read, &items_written); + unicodestr = plist_utf8_to_utf16(data->strval, data->length, &items_read, &items_written); write_unicode(bplist_buff, unicodestr, items_written); free(unicodestr); } |