| 771 | /* acl_vstring_insert - insert text into string */ |
| 772 | |
| 773 | ACL_VSTRING *acl_vstring_insert(ACL_VSTRING *vp, size_t start, |
| 774 | const char *buf, size_t len) |
| 775 | { |
| 776 | const char *myname = "acl_vstring_insert"; |
| 777 | size_t new_len, n; |
| 778 | |
| 779 | /* |
| 780 | * Sanity check. |
| 781 | */ |
| 782 | if (start >= ACL_VSTRING_LEN(vp)) { |
| 783 | acl_msg_panic("%s(%d): bad start %ld", |
| 784 | myname, __LINE__, (long) start); |
| 785 | } |
| 786 | |
| 787 | /* |
| 788 | * Move the existing content and copy the new content. |
| 789 | */ |
| 790 | new_len = ACL_VSTRING_LEN(vp) + len; |
| 791 | ACL_VSTRING_SPACE(vp, (ssize_t) len); |
| 792 | |
| 793 | n = acl_vstring_avail(vp); |
| 794 | if (len > (size_t) n) { |
| 795 | len = n; |
| 796 | } |
| 797 | |
| 798 | if (len > 0) { |
| 799 | memmove(acl_vstring_str(vp) + start + len, |
| 800 | acl_vstring_str(vp) + start, |
| 801 | ACL_VSTRING_LEN(vp) - start); |
| 802 | memcpy(acl_vstring_str(vp) + start, buf, len); |
| 803 | ACL_VSTRING_AT_OFFSET(vp, (int) new_len); |
| 804 | ACL_VSTRING_TERMINATE(vp); |
| 805 | } |
| 806 | |
| 807 | return vp; |
| 808 | } |
| 809 | |
| 810 | /* acl_vstring_prepend - prepend text to string */ |
| 811 |
no test coverage detected
searching dependent graphs…