History

DisVM will now only use 0 initialized memory. - The alloc_memory function will only return 0 initialize memory - calloc_memory was removed

Floating point division is now relying on underlying FPU and IEEE for behavior with respect to divide by 0

arr committed 9 years ago

Commit b92328e1 parent bd1f49311 files · +48 −112Browse files

Showing the changes to src/vm/string.cpp (1 of 11 files). Show all

Unified · Split

src/vm/string.cpp+7−7
@@ -217,7 +217,7 @@ vm_string_t::vm_string_t(std::size_t encoded_str_len, const uint8_t *encoded_str · 216 unmodified lines
217217 {
218218 // If we are going to allocate, make sure it is larger than needed.
219219 _length_max = compute_max_length(_length);
220− _mem.alloc = calloc_memory<uint8_t>(_length_max * _character_size);
220+ _mem.alloc = alloc_memory<uint8_t>(_length_max * _character_size);
221221 _is_alloc = true;
222222
223223 dest = _mem.alloc;
@@ -248,7 +248,7 @@ vm_string_t::vm_string_t(const vm_string_t &s1, const vm_string_t &s2) · 24 unmodified lines
248248 , _length_max{ compute_max_length(s1._length + s2._length) }
249249 , _mem{}
250250 {
251− _mem.alloc = calloc_memory<uint8_t>(_length_max * _character_size);
251+ _mem.alloc = alloc_memory<uint8_t>(_length_max * _character_size);
252252
253253 const auto s1_data = (s1._is_alloc) ? s1._mem.alloc : s1._mem.local;
254254 const auto s2_data = (s2._is_alloc) ? s2._mem.alloc : s2._mem.local;
@@ -290,7 +290,7 @@ vm_string_t::vm_string_t(const vm_string_t &other, word_t begin_index, word_t en · 35 unmodified lines
290290 if (_is_alloc)
291291 {
292292 src = other._mem.alloc;
293− _mem.alloc = calloc_memory<uint8_t>(_length_max);
293+ _mem.alloc = alloc_memory<uint8_t>(_length_max);
294294 dest = _mem.alloc;
295295 }
296296
@@ -358,9 +358,9 @@ vm_string_t &vm_string_t::append(const vm_string_t &other) · 61 unmodified lines
358358
359359 // Check if this string and the supplied string have the same character size.
360360 if (new_is_rune)
361− new_source = calloc_memory<uint8_t>(new_length_max * sizeof(rune_t));
361+ new_source = alloc_memory<uint8_t>(new_length_max * sizeof(rune_t));
362362 else
363− new_source = calloc_memory<uint8_t>(new_length_max);
363+ new_source = alloc_memory<uint8_t>(new_length_max);
364364
365365 // Combine the two string sources
366366 combine(
@@ -449,7 +449,7 @@ void vm_string_t::set_rune(word_t index, rune_t value) · 82 unmodified lines
449449 assert(_character_size == sizeof(rune_t));
450450
451451 _length_max = (_length == 0) ? static_cast<word_t>(compute_max_length(_mem.local)) : compute_max_length(_length);
452− auto new_alloc = calloc_memory<rune_t>(_length_max * _character_size);
452+ auto new_alloc = alloc_memory<rune_t>(_length_max * _character_size);
453453
454454 // Copy source into the new alloc.
455455 copy_characters_to(new_alloc, 0, source, _length);
@@ -467,7 +467,7 @@ void vm_string_t::set_rune(word_t index, rune_t value) · 11 unmodified lines
467467 else if (static_cast<word_t>(_length_max) <= index) // Check if string can accomodate the new character.
468468 {
469469 _length_max = (_length == 0) ? static_cast<word_t>(compute_max_length(_mem.local)) : compute_max_length(_length);
470− auto new_alloc = calloc_memory<uint8_t>(_length_max * _character_size);
470+ auto new_alloc = alloc_memory<uint8_t>(_length_max * _character_size);
471471 std::memcpy(new_alloc, source, _length * _character_size);
472472
473473 // Free memory, if allocated