Article View: comp.sys.amiga.tech
Article #498Re: regex.library - regular expression library
From: Jim Mackraz
Date: Sun, 16 Jul 1989 19:22
Date: Sun, 16 Jul 1989 19:22
58 lines
2715 bytes
2715 bytes
In article <15161@watdragon.waterloo.edu> ehoogerbeets@rose.waterloo.edu (Edwin Hoogerbeets) writes:
)
)Hi, I just managed to shoehorn the Gnu regular expression package
)into an Amiga sharable library. (with some assembler glue)
Great!
)And it works. Almost. That is, it works only if you have one copy
)running at a time. So I suspect there is something in there that isn't
)re-entrant.
Probably correct.
)I've attached the global variables to the struct RegexBase, so they are
)different for each OpenLibrary() call.
Stop. This is dead wrong: the variables in your library base are
SHARED, not one-per.
If the source uses any globals at all, you'll probably have to package
them in a per-caller data structure. Allocate one on specific request,
not OpenLibrary (since there really isn't any support for associating
the per-caller data structure with a caller), and call the pointer
you return to the requester a "handle," which must be passed to all
subsequent calls that have "state."
)That does not seem to be the problem. I do have to use the Manx
)heapmem.o to access the realloc() call.
Well, this might be ANOTHER problem. You can VERY EASILY write malloc,
free, and realloc, in C, and never worry again. What you *won't* have
(nor is it appropriate for you library) is automatic cleanup on
exit that heapmem.o supports.
)My question is this: are the routines in heapmem.o re-entrant? (ie.
)free(), malloc(), realloc()) Are there any other Manx library routines
)that I should avoid?
Watch it for any routines that do "per-process" stuff like cleaning
up. All the fopen() calls are probably unusable. Sprintf() OK, fprintf()
not OK.
)If I get this resolved, I shall send it to Bob soon. (no excuse for
)not having regular expression searching anymore! Like in dme, hint,
)hint... ;-)
I think it will be a great contribution if it is OK fast and not too huge.
(And doesn't use a GNU-bodacious amount of stack.)
)Thanks for any suggestions.
)Edwin
jimm
--
Jim Mackraz, I and I Computing "... the signs are very ominous,
{cbmvax,well,oliveb}!amiga!jimm and a chill wind blows."
- Justice Blackmun
Opinions are my own. Comments are not to be taken as Commodore official policy.
Technical Details
Message-ID:
<4119@amiga.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!oliveb!amiga!jimmReferences:
<59256@linus.UUCP> <15161@watdragon.waterloo.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!oliveb!amiga!jimm From: jimm@amiga.UUCP (Jim Mackraz) Newsgroups: comp.sys.amiga.tech Subject: Re: regex.library - regular expression library Message-ID: <4119@amiga.UUCP> Date: 16 Jul 89 19:22:46 GMT References: <59256@linus.UUCP> <15161@watdragon.waterloo.edu> Reply-To: jimm@cloyd.UUCP (Jim Mackraz) Organization: Commodore-Amiga Inc, Los Gatos CA Lines: 58