tweaks: order two functions more sensibly

This commit is contained in:
Benno Schulenberg 2019-10-15 16:24:06 +02:00
parent f26c121ca9
commit fdeab9b4c9

View File

@ -312,16 +312,6 @@ void *nrealloc(void *ptr, size_t howmuch)
return r; return r;
} }
/* Return an allocated copy of the first n characters of the given string. */
char *measured_copy(const char *src, size_t n)
{
char *dest = charalloc(n);
strncpy(dest, src, n);
return dest;
}
/* Return an appropriately reallocated dest string holding a copy of src. /* Return an appropriately reallocated dest string holding a copy of src.
* Usage: "dest = mallocstrcpy(dest, src);". */ * Usage: "dest = mallocstrcpy(dest, src);". */
char *mallocstrcpy(char *dest, const char *src) char *mallocstrcpy(char *dest, const char *src)
@ -334,6 +324,16 @@ char *mallocstrcpy(char *dest, const char *src)
return dest; return dest;
} }
/* Return an allocated copy of the first n characters of the given string. */
char *measured_copy(const char *src, size_t n)
{
char *dest = charalloc(n);
strncpy(dest, src, n);
return dest;
}
/* Return an allocated copy of the given string. */ /* Return an allocated copy of the given string. */
char *copy_of(const char *string) char *copy_of(const char *string)
{ {