intern.c File Reference

Library for pooling common strings. More...

#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <unistd.h>
#include "fallback.h"
#include "util.h"
#include "wutil.h"
#include "common.h"
#include "intern.h"

Functions

const wchar_t * intern (const wchar_t *in)
 Return an identical copy of the specified string from a pool of unique strings.
const wchar_t * intern_static (const wchar_t *in)
 Insert the specified string literal into the pool of unique strings.
static void clear_value (void *key, void *data)
 Free the specified key/value pair.
void intern_free_all ()
 Free all interned strings.

Variables

static hash_table_tintern_table = 0
 Table of interned strings.
static hash_table_tintern_static_table = 0
 Table of static interned strings.


Detailed Description

Library for pooling common strings.


Function Documentation

static void clear_value ( void *  key,
void *  data 
) [static]

Free the specified key/value pair.

Should only be called by intern_free_all at shutdown

References debug().

Referenced by intern_free_all().

const wchar_t* intern ( const wchar_t *  in  ) 

Return an identical copy of the specified string from a pool of unique strings.

If the string was not in the pool, add a copy.

Parameters:
in the string to return an interned copy of

References DIE_MEM, hash_get(), hash_init(), hash_put(), hash_wcs_cmp(), and hash_wcs_func().

Referenced by autoload_names(), builtin_source(), complete_get_exact_entry(), function_add(), history_create_mode(), input_mapping_add(), main(), parse_util_load_internal(), and parser_push_block().

void intern_free_all (  ) 

Free all interned strings.

Only call this at shutdown.

References clear_value(), hash_destroy(), and hash_foreach().

Referenced by main().

const wchar_t* intern_static ( const wchar_t *  in  ) 

Insert the specified string literal into the pool of unique strings.

The string will not first be copied, and it will not be free'd on exit.

Parameters:
in the string to add to the interned pool

References DIE_MEM, hash_get(), hash_init(), hash_put(), hash_wcs_cmp(), and hash_wcs_func().

Referenced by builtin_init(), and builtin_source().


Generated on Sun Mar 8 15:46:55 2009 for fish by  doxygen 1.5.6