CONTENTS | INDEX | PREV | NEXT

 memset
 setmem
 clrmem
 bzero 

 NAME
  memset  -   ANSI    set memory buffer to a byte value
  setmem  -   DEFACTO set memory buffer to a byte value
  clrmem  -   DICE    zero out a memory buffer
  bzero   -   UNIX    zero out a memory buffer

 SYNOPSIS
  void *ptr = memset(buf, c, n);
  void *ptr = setmem(buf, n, c);
  void *ptr = clrmem(buf, n);
  void *ptr = bzero(buf, n);

  void *buf;
  int c;
  size_t n;

 FUNCTION
  fill a memory buffer with the specified character, c.  c is
  converted to an unsigned char by the fill routine before beginning
  the fill.  n bytes are filled.

 WARNING
  Again, watch out for argument ordering, especially for the
  ANSI memset() call.  Again, the ANSI committee really screwed
  up the call ordering so there is another defacto standard
  call called setmem().

  bzero() exists for UNIX compatibility, and clrmem() is yet another
  call (this time introduced by DICE, sorry! :-)).

  memset() and setmem() are the most portable calls.

 EXAMPLE
  #include <string.h>
  #include <assert.h>
  #include <stdlib.h>

  main()
  {
      char buf[32];
      char *b;

      b = setmem(buf, 32, 0);
      assert(b == buf);

      b = setmem(buf, 4, 'a');
      b = memset(buf + 4, 'b' , 4);
      puts(buf);      /*  aaaabbbb    */

      return(0);
  }


 INPUTS
  void *buf;      pointer to buffer to fill
  int c;          character to copy into buffer (setmem, memset)
  size_t n;       # of bytes to fill

 RESULTS
  void *ptr;      pointer to buffer (== buf).

 SEE ALSO
  malloc, calloc, strdup, movmem, cmpmem