append.c 560 B

1234567891011121314151617181920
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. // Copyright © 2019 Ariadne Devos
  3. /* sHT -- append and iterate a suffix */
  4. #include <stddef.h>
  5. #include <sHT/index.h>
  6. #include <sHT/string.h>
  7. size_t
  8. sHT_append(char *to, const char *from, size_t length0, size_t length1, size_t i0, size_t i1)
  9. {
  10. /* Compute the number of bytes that can be read and written. */
  11. size_t todo = sHT_min_size(length0 - i0, length1 - i1);
  12. size_t i;
  13. /* Then copy them. */
  14. sHT_index_iterate(i, todo)
  15. to[i0 + i] = from[i1 + i];
  16. return i;
  17. }