(flex.info)Loading and Unloading Serialized Tables


Next: Tables File Format Prev: Creating Serialized Tables Up: Serialized Tables
Enter node , (file) or (file)node

22.2 Loading and Unloading Serialized Tables
============================================

If you've built your scanner with '%option tables-file', then you must
load the scanner tables at runtime.  This can be accomplished with the
following function:

 -- Function: int yytables_fload (FILE* FP [, yyscan_t SCANNER])
     Locates scanner tables in the stream pointed to by FP and loads
     them.  Memory for the tables is allocated via 'yyalloc'.  You must
     call this function before the first call to 'yylex'.  The argument
     SCANNER only appears in the reentrant scanner.  This function
     returns '0' (zero) on success, or non-zero on error.

   The loaded tables are *not* automatically destroyed (unloaded) when
you call 'yylex_destroy'.  The reason is that you may create several
scanners of the same type (in a reentrant scanner), each of which needs
access to these tables.  To avoid a nasty memory leak, you must call the
following function:

 -- Function: int yytables_destroy ([yyscan_t SCANNER])
     Unloads the scanner tables.  The tables must be loaded again before
     you can scan any more data.  The argument SCANNER only appears in
     the reentrant scanner.  This function returns '0' (zero) on
     success, or non-zero on error.

   *The functions 'yytables_fload' and 'yytables_destroy' are not
thread-safe.*  You must ensure that these functions are called exactly
once (for each scanner type) in a threaded program, before any thread
calls 'yylex'.  After the tables are loaded, they are never written to,
and no thread protection is required thereafter - until you destroy
them.


automatically generated by info2www version 1.2.2.9