FreeBSD/contrib/binutils/bfd/elf.c
/* return a malloc'ed copy of a string at START which is at
   most MAX bytes long, possibly without a terminating '\0'.
   the copy will always have a terminating '\0'.  */
return a malloc'ed copy of a string at START which is at
most MAX bytes long, possibly without a terminating '\0'.
the copy will always have a terminating '\0'.
return a malloc ' ed copy of a string at START which is at most MAX bytes long possibly without a terminating ' \ 0 ' . the copy will always have a terminating ' \ 0 ' .
char *
_bfd_elfcore_strndup (bfd *abfd, char *start, size_t max)
{
  char *dups;
  char *end = memchr (start, '\0', max);
  size_t len;
  if (end == NULL)
    len = max;
  else
    len = end - start;
  dups = bfd_alloc (abfd, len + 1);
  if (dups == NULL)
    return NULL;
  memcpy (dups, start, len);
  dups[len] = '\0';
  return dups;
}
char * _bfd_elfcore_strndup ( bfd * abfd , char * start , size_t max ) { char * dups ; char * end = memchr ( start , ' \0 ' , max ) ; size_t len ; if ( end == NULL ) len = max ; else len = end - start ; dups = bfd_alloc ( abfd , len + 1 ) ; if ( dups == NULL ) return NULL ; memcpy ( dups , start , len ) ; dups [ len ] = ' \0 ' ; return dups ; }
return a malloc'ed copy of a string at START which is at
most MAX bytes long, possibly without a terminating '\0'.
return a malloc ' ed copy of a string at START which is at most MAX bytes long possibly without a terminating ' \ 0 ' .