[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SSTRDUP & memory management; file i/o tests and related
From: |
William S. Shu |
Subject: |
SSTRDUP & memory management; file i/o tests and related |
Date: |
Mon, 18 Oct 1999 17:53:07 +0100 |
Marcus,
Sometime ago you showed a better way of creating labels (and hence various
strings). I stored the code for later use (givn below) but discover I do
not know how to deAllocate any memory claimed by SSTRDUP.
Unfortunately, cant make out from the doc. For instance, I am not sure if
FREEBLOCK(block)
will do it.
In fact, I ended up wondering what the following are:
OSTRDUP(obj, str)
STRDUP(str)
ZSTRDUP(aZone, str)
On a separate note, how does one detect/test for end-of-line, end-of-file,
read error, etc., after creating one with, say,
// open the file
f = [InFile create: [self getZone] withName: buf];
Thanks
William.
P/S: still using 1.4.1 on windows 98, but answers for 2.0.1 are fine too.
---[ code ---
>>>>> "DS" == Darren Schreiber <address@hidden> writes:
DS> So, first question what is a better way of doing this naming?
Here's a robust way to do that:
#import <simtools.h> // initSwarm
#import <defobj.h> // SSTRDUP
#include <misc.h> // sprintf
const char *
makeLabel (int agentID)
{
char buf[1 + DSIZE (int) + 1];
sprintf (buf, "C%d", agentID);
return SSTRDUP (buf);
}
==================================
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.