[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Pointer question about Discrete2d
From: |
Paul E Johnson |
Subject: |
Pointer question about Discrete2d |
Date: |
Thu, 05 Apr 2001 08:36:07 -0500 |
There is a pointer usage in swarm, src/space/Discrete2d.m, that I don't
understand.
Discrete2d.h declares
long * offsets;
It is allocated in Discrete2d.m
- makeOffsets
{
unsigned i;
// precalculate offsets based on the y coordinate. This lets
// us avoid arbitrary multiplication in array lookup.
offsets = [getZone (self) alloc: ysize * sizeof (*offsets)];
for (i = 0; i < ysize; i++)
offsets[i] = xsize * i; // cache this multipliction
return self;
}
I don't understand why the aloc is not
offsets = [getZone (self) alloc: ysize * sizeof (long)];
I don't get what sizeof(*offsets) means.
Can someone explain for a poor, old country doctor?
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
- Pointer question about Discrete2d,
Paul E Johnson <=