pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:37:   #include "signal_handler.h"   #include "builtin_functions.h"   #include "bignum.h"   #include "peep.h"   #include "docode.h"   #include "lex.h"   #include "pike_float.h"   #include "stuff.h"   #include "pike_compiler.h"   #include "port.h" + #include "siphash24.h"      #include <errno.h>      #ifdef HAVE_POLL   #ifdef HAVE_POLL_H   #include <poll.h>   #endif /* HAVE_POLL_H */      #ifdef HAVE_SYS_POLL_H   #include <sys/poll.h>
pike.git/src/builtin_functions.c:458:    *! @note    *! This hash function differs from the one provided by @[hash_value()],    *! in that @[hash_value()] returns a process specific value.    *!    *! @seealso    *! @[hash_7_0()], @[hash_7_4()], @[hash_8_0()], @[hash_value]    */   static void f_hash( INT32 args )   {    size_t res; -  ptrdiff_t len = 0; +        if( TYPEOF(Pike_sp[-args]) != PIKE_T_STRING )    PIKE_ERROR("hash","Argument is not a string\n",Pike_sp,args);    -  len = Pike_sp[-args].u.string->len; +  res = pike_string_siphash24(Pike_sp[-args].u.string, 0) & 0x7fffffff;    -  res = hashmem_siphash24( Pike_sp[-args].u.string->str, -  len << Pike_sp[-args].u.string->size_shift) & -  0x7fffffff; -  +     if( args > 1 ) {    if(TYPEOF(Pike_sp[1-args]) != T_INT)    SIMPLE_ARG_TYPE_ERROR("hash",2,"int");       if(Pike_sp[1-args].u.integer <= 0)    PIKE_ERROR("hash", "Modulo < 1.\n", Pike_sp, args);       res %= Pike_sp[1-args].u.integer;    }