swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Report on last release


From: Roger M. Burkhart
Subject: Re: Report on last release
Date: Wed, 13 Dec 1995 08:29:24 -0600

>     >> 2. Warnings: There are lots of warnings with calloc, malloc and
>     >> the like. Is it only here, or everywhere?
> 
>     Nelson> Maybe worse there, but I've seen them here. They're good
>     Nelson> warnings, in a way, since (most) of Swarm shouldn't be
>     Nelson> using those calls.
> 
> I use them for instance in the neurolib to set up arrays, which aren't
> worth the overhead of using the collections stuff. Anyways, it's just
> a matter of including the proper header files.

There's by no means any reason you shouldn't be able to use malloc, etc.,
since all kinds of libraries are still using them, as do the current
interim Zone objects which are nothing but a malloc pass-through.  Even
when we reimplement Zone with its own page-based allocator it'll probably
still use malloc for its basic memory source since obtaining memory
directly from the OS (with sbrk()) tends to be unfriendly to other
allocators (though we could supply a malloc implementation also).

Note that Zone also supports non-object, raw block allocations just like
malloc (alloc:, free:, allocBlock:, freeBlock:) which will eventually be
much more highly tuned than malloc for large numbers of small blocks and
keep locality of allocations as well (not to mention a two-tier garbage
collection scheme that distinguishes objects from other allocations).
Nelson is right that long-term you probably shouldn't be using the malloc
calls, but for now there's no special advantage of Zone.

For arrays, there's a pending version of an Array collections type due to
appear in the next release.  It gives an interface consistent with other
collections, but also lets you get at the internal contiguous block
allocation if you want to do faster tricks yourself.  You can let it do
the allocation for you, or supply your own allocation if you wish.

Under ANSI/ISO C (and gcc), the proper declarations for malloc, etc. are
included by #include <stdlib.h>.  That should suppress compiler warnings,
so long as you use them according to declared parameter/return types.  The
only C header automatically included by standard Swarm headers is <stddef.h>,
which defines only types (and NULL and offsetof macro), not functions.

On compiler warnings in general, I prefer the zero-tolerance policy, in
which I set CFLAGS to include -Wall -Werror.  This causes warnings to be
treated the same as errors, but all of Swarm wouldn't compile yet that way.
gcc is sticky about some of the warnings it generates under -Wall, but the
consistency of the code is probably worth it.

Roger


reply via email to

[Prev in Thread] Current Thread [Next in Thread]