Make sure the buffer has room for nchars more characters.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me | |||
| integer, | intent(in) | :: | nchars |
pure subroutine reserve(me, nchars) class(text_buffer),intent(inout) :: me integer,intent(in) :: nchars character(len=:),allocatable :: tmp integer :: new_size if (.not. allocated(me%s)) then allocate(character(len=max(nchars, 1024)) :: me%s) me%n = 0 else if (me%n + nchars > len(me%s)) then new_size = max(2*len(me%s), me%n + nchars) allocate(character(len=new_size) :: tmp) tmp(1:me%n) = me%s(1:me%n) call move_alloc(tmp, me%s) end if end subroutine reserve