BSD/SYSV bzero/memset

BSD/SYSV bzero/memset

Post by Simon Marsha » Wed, 25 Sep 1991 04:52:56



        Sorry to hassle this group again, but I am lead to believe that
     BSD versions of Unix comes with bzero, while USG and SYSV come with
     memset.  Am I being lead right?  I need to know to reduce the
     complexity of an #ifdef in some (ultra) portable code; I want to be
     able to say:

#if defined(BSD)
#define         ZERO(s,n)       bzero((s),(n))
#else
#define         ZERO(s,n)       memset((s), 0, (n))
#endif

        Are there any other considerations I need to make?  Post/email is
     fine.

        Thanx, Simon.
_______________________________________________________________________________
Simon Marshall, Dept. of Computer Science, University of Hull, Hull HU6 7RX, UK
              "``La la la la la la la la la'' means I love you."

 
 
 

1. [S.Marshall@uk.ac.hull.seq: BSD/SYSV bzero/memset]

| I am lead to believe that BSD versions of Unix comes with bzero, while USG
| and SYSV come with memset.  Am I being lead right?  I need to know to reduce
| the complexity of an #ifdef in some (ultra) portable code; I want to be able
| to say:

| #if defined(BSD)
| #define               ZERO(s,n)       bzero((s),(n))
| #else
| #define               ZERO(s,n)       memset((s), 0, (n))
| #endif

| Is this the best way to do this?  Or should I just assume that everyone has
| bzero accept SYSV?  Post/email is fine.

        Thanks to the 100s who replied; I couldn't reply to everyone.
     Most people seemed to think it was mostly OK & reliable, except that
     that's not quite enough!  The solution?  Write my own.  This is it.
     Anything wrong with it?  This is for writing zeros into a string.

/*
 * Why don't I use memset?  Err...  Or is it bzero?  Cos it's easier
 * to write my own:
 */

static void Zero (start)
  char  *start;
{
    char  *c;
    int   length = strlen (start);

    for (c=start; c<(start+length); c++)

        thanx, Simon.   *c = '\0';

_______________________________________________________________________________
Simon Marshall, Dept. of Computer Science, University of Hull, Hull HU6 7RX, UK
              "``La la la la la la la la la'' means I love you."

2. Device not connected

3. What's the difference between SYSV and BSD?

4. bash: ./Install: bad interpreter: No such file or directory

5. help remote print to bsd from sysV

6. Closure to getty,uugetty

7. dump (BSD) for SYSV?

8. Grep/Perl and regular expressions

9. SYSV / BSD file systems

10. Main differences between BSD and SysV?

11. SYSV vs. BSD (Bourne shell)

12. cross mounting fs between SysV and BSD

13. SYSV/BSD Compatibility