Skip to content
Snippets Groups Projects
Select Git revision
  • a3ce270c3cf79a6159e323910c20c34c127520f4
  • master default protected
  • 9.0
  • marcus/wix3
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

stralloc.c

Blame
  • stralloc.c 8.17 KiB
    #include "global.h"
    #include "stralloc.h"
    #include "macros.h"
    #include "dynamic_buffer.h"
    #include "macros.h"
    #include "memory.h"
    #include "error.h"
    
    static struct lpc_string *base_table[HTABLE_SIZE];
    static unsigned INT32 full_hash_value;
    
    /*
     */
    static unsigned int StrHash(const char *s,int len)
    {
      full_hash_value=hashmem((unsigned char *)s, len, 20);
      return full_hash_value % HTABLE_SIZE;
    }
    
    #ifdef DEBUG
    void check_string(struct lpc_string *s)
    {
      if(debug_findstring(s) !=s)
        fatal("Shared string not shared.\n");
    
      checked((void *)s,1);
    }
    
    void verify_shared_strings_tables(int pass)
    {
      unsigned int e, h;
      struct lpc_string *s;
    
      for(e=0;e<HTABLE_SIZE;e++)
      {
        h=0;
        for(s=base_table[e];s;s=s->next)
        {
          if(pass)
          {
    	if(checked((void *)s,0)!=s->refs)
    	{
    	  fatal("Shared string has wrong number of refs '%s'.\n",s->str);
    	}
    	continue;
          }
          h++;
          if(s->len < 0)
    	fatal("Shared string shorter than zero bytes.\n");
    
          if(s->refs <= 0)
    	fatal("Shared string had too few references.\n");
    
          if(s->str[s->len])
    	fatal("Shared string didn't end with a zero.\n");
    
          if(StrHash(s->str, s->len) != e)
    	fatal("Shared string hashed to wrong place.\n");
    
          if(s->hval != full_hash_value)
    	fatal("Shared string hashed to other number.\n");
    	
          if(h>10000)
          {
    	struct lpc_string *s2;
    	for(s2=s;s2;s2=s2->next)
    	  if(s2 == s)
    	    fatal("Shared string table is cyclic.\n");
    	h=0;
          }