home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / memchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1020 b   |  63 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: memchr.c,v 1.4 1997/01/01 03:41:10 ldp Exp $
  4.  
  5.     Desc: ANSI C function memchr()
  6.     Lang: english
  7. */
  8. #include <proto/exec.h>
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <string.h>
  14.  
  15.     void * memchr (
  16.  
  17. /*  SYNOPSIS */
  18.     const void * mem,
  19.     int         c,
  20.     size_t         n)
  21.  
  22. /*  FUNCTION
  23.     Copy the contents of a part of memory to another. Both areas
  24.     must not overlap. If they do, use memmove().
  25.  
  26.     INPUTS
  27.     dest - The first byte of the destination area in memory
  28.     src - The first byte of the source area in memory
  29.     count - How many bytes to copy
  30.  
  31.     RESULT
  32.     dest.
  33.  
  34.     NOTES
  35.  
  36.     EXAMPLE
  37.  
  38.     BUGS
  39.  
  40.     SEE ALSO
  41.  
  42.     INTERNALS
  43.  
  44.     HISTORY
  45.     24-12-95    digulla created
  46.  
  47. ******************************************************************************/
  48. {
  49.     const char * ptr = (char *)mem;
  50.  
  51.     while (n)
  52.     {
  53.     if (*ptr == c)
  54.         return ((void *)ptr);
  55.  
  56.     n --;
  57.     ptr ++;
  58.     }
  59.  
  60.     return NULL;
  61. } /* memchr */
  62.  
  63.