Article View: comp.sys.amiga.tech
Article #10137Manx help
From: Jim Pritchett
Date: Thu, 27 Oct 1988 23:37
Date: Thu, 27 Oct 1988 23:37
65 lines
1974 bytes
1974 bytes
Hello,
I am making my first attempt to use the DOS functions from a C program.
I have all the manuals in one form or another, but I haven't been able to find
the problem with the code below. Could one of the C experts out there help me
out? Basically the problem is that although the test program below runs fine,
the system becomes severely unstable and crashes within a couple of commands
after the program terminates. I'm sure that there is a problem with my
(mis)understanding of locks, but I don't know what it is. Here is the source
code to my program (Aztec C v3.6a, SDB):
#include <stdio.h>
main()
{
char cd[108];
getcwd(cd, 108);
}
# include <functions.h>
# include <exec/types.h>
# include <libraries/dosextens.h>
getcwd(cd, length)
char *cd;
int length;
{
char name[108];
struct FileLock *lockcd, *lockram;
struct FileInfoBlock *fib;
short success;
lockram = Lock("ram:t", ACCESS_READ);
lockcd = CurrentDir(lockram);
fib = AllocMem((long)sizeof(fib), 1L);
success = Examine(lockcd, fib);
strcpy(name, fib->fib_FileName);
printf(" %s\n", name);
UnLock(lockram);
lockram = CurrentDir(lockcd);
UnLock(lockcd);
UnLock(lockram);
}
Thanks,
Jim Pritchett
UUCP: killer!gtmvax!dms3b1!caleb!jdp
P.S. I noticed after the fact that I had not returned the memory allocated
to the FileInfoBlock. However, this should not destabilize my system.
}
Technical Details
Message-ID:
<5918@killer.DALLAS.TX.US>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!mit-eddie!killer!jdpShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!mit-eddie!killer!jdp From: jdp@killer.DALLAS.TX.US (Jim Pritchett) Newsgroups: comp.sys.amiga.tech Subject: Manx help Keywords: Manx Aztec DOS Locks Message-ID: <5918@killer.DALLAS.TX.US> Date: 27 Oct 88 23:37:23 GMT Organization: The Unix(R) Connection, Dallas, Texas Lines: 65