[comp.sys.amiga.programmer] What is setmem in Aztec's c.lib for?

alcaman@opal.cs.tu-berlin.de (Alexander Weidt) (02/15/91)

Hi..
  I desperatley need some documentation on the setmem function found in
Aztec's c.lib. The function is documented NOWHERE, and i am at a loss of
what to do.. B-( please, if one of you out there knows about it, and can
provide *any* info on it, i would be forever thankful...If anyone has the
source.. i would not be adverse to receiving it by mail.. B-)

thanks in advance..
--
God is real unless declared integer.


--
Alexander Weidt     | UUCP: alcaman@tubopal.UUCP (alcaman@opal.cs.tu-berlin.de)
D-1000 31           |         ...!unido!tub!opal!alcaman (Europe) 
Kurfuerstendamm 74  |         ...!pyramid!tub!opal!alcaman (World)
Tel: (030) 3278112  | BITNET: alcaman%tubopal@DB0TUI11.BITNET (saves $$$)

dillon@overload.Berkeley.CA.US (Matthew Dillon) (02/17/91)

In article <2662@opal.cs.tu-berlin.de> alcaman@opal.cs.tu-berlin.de (Alexander Weidt) writes:
>Hi..
>  I desperatley need some documentation on the setmem function found in
>Aztec's c.lib. The function is documented NOWHERE, and i am at a loss of
>
>Alexander Weidt     | UUCP: alcaman@tubopal.UUCP (alcaman@opal.cs.tu-berlin.de)

    setmem is pretty simple, it sets an area of memory to a character.
    You pass it a pointer to the base of the area to be jam set, the number
    of bytes, and the value to set each location to (0-255).  setmem()
    normally returns its first argument but different compilers might
    implement the return value differently.

    void *setmem(void *, size_t, int);

    As to how it works, in C it does this (but most compilers actually
    write the thing in assembly so it goes fast):

    void *
    setmem(base, bytes, c)
    void *base;
    long bytes;
    int c;
    {
	char *ptr = base;

	while (bytes--)
	    *ptr++ = (char)c;
	return(base);
    }

				    -Matt
--

    Matthew Dillon	    dillon@Overload.Berkeley.CA.US
    891 Regal Rd.	    uunet.uu.net!overload!dillon
    Berkeley, Ca. 94708
    USA

shields@yunexus.YorkU.CA (Paul Shields) (02/19/91)

alcaman@opal.cs.tu-berlin.de (Alexander Weidt) writes:
>  I desperatley need some documentation on the setmem function found in
>Aztec's c.lib. The function is documented NOWHERE, and i am at a loss of
>what to do.. 

Having a source license for Aztec 5.0d, I grepped through it looking
for setmem.  There is assembler source string/setmem.a68. Note that
the function is identical to memset(), the well-known ANSI C function,
except that the second and third parameters are reversed.  I suggest
you use memset() instead.  Here's a quote from the included doc:

; Synopsis
; void setmem(void *s, size_t n, inc c);
;
; Description
;   The setmem function copies the value of c (converted to an
; unsigned char) into each of the first n characters of the object
; pointed to by s.
; 
; Returns
;   The setmem function returns no value.

 
--
parts of the above are copyright 1989 Manx Software Systems, Inc. and
are quoted for review purposes only.
P.