BOOTSTRAP (kutils) functions


LIBRARY ROUTINE

kstring_ncopy - copy up to n characters of a string

LIBRARY CALL

char *kstring_ncopy(
   const char *istr,
   size_t      num,
   char       *ostr)

INPUT

OUTPUT

RETURN VALUE

The copied string 'ostr', if it is non-NULL, or the allocated string if 'ostr' is NULL. NULL is returned if 'istr' is NULL, or if an error occurs.

DESCRIPTION

This routine concatenates two strings together, into a third. If the output parameter is not NULL, the concatenated string is put into that string. Otherwise, the resulting string is allocated by kmalloc(). In either case, the resulting string is returned. Finally, this routine puts a terminating '\\0' on the end of the new string.

Note that if 'ostr' is non-NULL, the calling routine must ensure that 'ostr' points to a memory buffer large enough to hold the copied string and terminating null character. If the buffer is not large enough, memory will be overwritten resulting in unpredicable program failure.

ADDITIONAL INFORMATION

none

EXAMPLES

none

SIDE EFFECTS

This routine uses kmalloc() to create a string that holds the result, if 'ostr' is NULL.

RESTRICTIONS

none

MODIFICATION

none

FILES

$BOOTSTRAP/objects/library/kutils/src/strings.c

SEE ALSO

kutils(3)

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.