SHOW:
|
|
- or go back to the newest paste.
| 1 | - | gap_buffer::gap_buffer() : |
| 1 | + | // Order of initialization of the next block is important |
| 2 | // - don't change unless you know what you are doing! | |
| 3 | uptr_type buffer; | |
| 4 | std::size_t buffer_size; | |
| 5 | char_type* lptr, rptr; // points to actual gap boundaries | |
| 6 | char_type* staging_lptr, staging_rptr; // points to represented gap | |
| 7 | ||
| 8 | std::size_t character_num; | |
| 9 | std::size_t codepoint_num; | |
| 10 | std::vector<char_type*> lines; | |
| 11 | ||
| 12 | gap_buffer::gap_buffer() : | |
| 13 | buffer(malloc(char_type[alloc_size] * sizeof(char_type), std::free) | |
| 14 | buffer_size(alloc_size), | |
| 15 | lptr(lptr_beg()), rptr(rptr_beg()), | |
| 16 | staging_lptr(lptr), staging_rptr(rptr), | |
| 17 | character_num(0), | |
| 18 | codepoint_num(0) {
| |
| 19 | } | |
| 20 | ||
| 21 | gap_buffer::gap_buffer(const gap_buffer& other) : | |
| 22 | buffer(malloc(char_type[other.buffer_size] * sizeof(char_type)), std::free), | |
| 23 | lptr(other.lptr), rptr(other.rptr), | |
| 24 | staging_lptr(other.staging_lptr), staging_rptr(other.staging_rptr), | |
| 25 | buffer_size(other.buffer_size), | |
| 26 | character_num(other.character_num), | |
| 27 | codepoint_num(other.codepoint_num), | |
| 28 | lines(other.lines) {
| |
| 29 | std::memcpy(lptr_beg(), other.lptr_beg(), lsize()); | |
| 30 | std::memcpy(rptr, other.rptr, rsize()); | |
| 31 | } |