[LCP]Regex Questions
ianezz at sodalia.it
ianezz at sodalia.it
Tue Nov 27 20:47:54 UTC 2001
Chuck Martin, aggrappandosi alla tastiera per non cadere, ha scritto:
> That makes it sound like preg in the above synopsis is allocated by
> regcomp.
AFAIK:
1) you have to allocate struc preg (either via malloc() or on stack).
2) regcomp() allocates other ancillary structures (for the compiled
version of the regexp), and stores their pointer in some fields of
the preg structure you passed.
3) regfree() should deallocate such ancillary structures.
4) then you can free() struct preg, if you used malloc().
freeing preg without a regfree() first should result in a leak.
--
UNIX diapers by Pannolini USPTO 2039887 http://www.uspto.gov
Matteo Ianeselli ianezz AT sodalia.it (+39) 0461 316452
Visita il LinuxTrent: http://www.linuxtrent.it
More information about the linuxCprogramming
mailing list