Skip to content
Snippets Groups Projects
Select Git revision
  • poly1305
  • master default
  • support_pre_UAL_arm_asm
  • skein
  • rsa-crt-hardening
  • chacha96
  • fat-library
  • versioned-symbols
  • curve25519
  • dsa-reorg
  • aead-api
  • set_key-changes
  • aes-reorg
  • nettle-2.7-fixes
  • size_t-changes
  • ecc-support
  • experimental-20050201
  • lsh-1.4.2
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
  • nettle_2.7.1_release_20130528
  • nettle_2.7_release_20130424
  • nettle_2.6_release_20130116
  • nettle_2.5_release_20120707
  • converted-master-branch-to-git
  • nettle_2.4_release_20110903
  • nettle_2.3_release_20110902
  • nettle_2.2_release_20110711
  • nettle_2.1_release_20100725
  • camellia_32bit_20100720
  • nettle_2.0_release_20090608
  • nettle_1.15_release_20061128
38 results

asn1.h

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    mapping.c 70.57 KiB
    /*
    || This file is part of Pike. For copyright information see COPYRIGHT.
    || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
    || for more information.
    */
    
    #include "global.h"
    #include "main.h"
    #include "object.h"
    #include "mapping.h"
    #include "svalue.h"
    #include "array.h"
    #include "pike_macros.h"
    #include "pike_error.h"
    #include "pike_memory.h"
    #include "pike_types.h"
    #include "dynamic_buffer.h"
    #include "interpret.h"
    #include "las.h"
    #include "gc.h"
    #include "stralloc.h"
    #include "pike_security.h"
    #include "block_allocator.h"
    #include "opcodes.h"
    #include "stuff.h"
    
    #define AVG_LINK_LENGTH 4
    #define MIN_LINK_LENGTH 1
    #define MAP_SLOTS(X) ((X)?((X)+((X)>>4)+8):0)
    
    struct mapping *first_mapping;
    
    struct mapping *gc_internal_mapping = 0;
    static struct mapping *gc_mark_mapping_pos = 0;
    
    #define unlink_mapping_data(M) do{				\
     struct mapping_data *md_=(M);					\
     if(md_->hardlinks) { md_->hardlinks--; md_->valrefs--; }	\
     free_mapping_data(M);						\
    }while(0)
    
    #define MAPPING_DATA_SIZE(HSIZE, KEYPAIRS) \
       PTR_TO_INT(MD_KEYPAIRS(0, HSIZE) + KEYPAIRS)
    
    static struct block_allocator mapping_allocator = BA_INIT_PAGES(sizeof(struct mapping), 2);
    void count_memory_in_mappings(size_t * num, size_t * size) {
        struct mapping *m;
        double datasize = 0.0;
        ba_count_all(&mapping_allocator, num, size);
        for(m=first_mapping;m;m=m->next) {
    	datasize+=MAPPING_DATA_SIZE(m->data->hashsize, m->data->num_keypairs) / (double) m->data->refs;
        }
        *size += (size_t) datasize;
    }
    
    void really_free_mapping(struct mapping * m) {
    #ifdef PIKE_DEBUG
      if (m->refs) {
    # ifdef DEBUG_MALLOC
        describe_something(m, T_MAPPING, 0,2,0, NULL);
    # endif
        Pike_fatal("really free mapping on mapping with %d refs.\n", m->refs);
      }
    #endif
      FREE_PROT(m);
      unlink_mapping_data(m->data);
      DOUBLEUNLINK(first_mapping, m);
      GC_FREE(m);
      ba_free(&mapping_allocator, m);
    }